DlistHeadT* DlistCreate() { DlistHeadT* ths = (DlistHeadT*) DlistHeapAllocate(NULL,sizeof(DlistHeadT)); DlistInit(ths); ths->flags |= ALLOCED; return ths; }
int main(int argc, char *argv[]) { Dlist *dl; DlistNode *dn; int i; dl = DlistInit(); if(dl == NULL) { fprintf(stderr,"DlistInit fails\n"); exit(1); } printf("appending: "); for(i=0; i < 10; i++) { printf("%d ",i); dn = DlistAppend(dl,(Hval)i); } printf("\nReading\n"); dn = dl->first; while(dn != NULL) { i = dn->value.i; printf("%d ",i); dn = dn->next; } printf("\nremoving Dlist\n"); DlistRemove(dl); dl = DlistInit(); if(dl == NULL) { fprintf(stderr,"DlistInit fails\n"); exit(1); } printf("prepending "); for(i=0; i < 10; i++) { printf("%d ",i); dn = DlistPrepend(dl,(Hval)i); } printf("\nReading\n"); dn = dl->first; while(dn != NULL) { i = dn->value.i; printf("%d ",i); dn = dn->next; } printf("\nremoving Dlist\n"); DlistRemove(dl); dl = DlistInit(); if(dl == NULL) { fprintf(stderr,"DlistInit fails\n"); exit(1); } printf("prepending "); for(i=0; i < 10; i++) { printf("%d ",i); dn = DlistPrepend(dl,(Hval)i); } dn = dl->first; for(i=0; i < 5; i++) { dn = dn->next; } printf("\ndeleting %d\n",dn->value.i); DlistDelete(dl,dn); dn = dl->first; while(dn != NULL) { i = dn->value.i; printf("%d ",i); dn = dn->next; } printf("\nremoving Dlist\n"); DlistRemove(dl); return(0); }