void freePagina(Pagina pagina){ Pagina tmp; while (pagina){ tmp = pagina; freeSeccoes(pagina->seccoes); freelink(pagina->linksExternos); freelink(pagina->linksInternos); pagina = pagina->proxima; free(tmp); } }
struct listnode *createlink(struct listnode *head,int *address,int t) { int info,count=0; struct listnode *p,*temp; freelink(head); /* to distroy old list if exist */ setfillstyle(SOLID_FILL,BLACK); bar(145,70,640,400); head=0; info=getdata(300,400,2,"ENTER A NUM(2 DIGI)0 EXIT"); if(info==0) return head; head=(struct listnode*)calloc(sizeof(struct listnode),1); if(head==0) { getdata(100,100,0,"Memory not avilable,con't create node"); return head; } head->num=info; head->padd=0; head->nadd=0; head->add=*address; head->pre=0; head->next=0; display(head,t); *address+=50; count++; while(1) { p=head; info=getdata(300,400,2,"ENTER A NUM(2 DIGI)0 EXIT"); if(info==0) return head; /* This example can dispaly 12 nodes maximum */ if(count<12) { temp=(struct listnode*)calloc(sizeof(struct listnode),1); if(temp==0) { getdata(100,100,0,"Memory not avilable,con't create node"); return head; } temp->num=info; temp->padd=0; temp->nadd=0; temp->add=*address; temp->pre=0; temp->next=0; for(p=head;p->next!=0;p=p->next); temp->pre=p; p->next=temp; p->nadd=temp->add; temp->padd=p->add; count++; *address+=50; } else getdata(300,400,0,"CAN'T TAKE MORE THAN 12 NODES"); display(head,t); } }