vendredi 27 février 2015

Abort trap 6: Freeing unallocated pointer

Here is code to destroy a circularly linked list. When it runs, it produces an abort trap 6: pointer being freed was not allocated



NODE *roamer = list->head;
do{
NODE *oldRoamer = roamer;
roamer = roamer->next;
printf("freeing prev");
free(oldRoamer);
printf("prev freed");
}while (roamer != NULL);


The program prints both printf statements a bunch of times, but then gives the error just after printing "freeing prev".


Aucun commentaire:

Enregistrer un commentaire