Name: Anonymous 2010-04-29 9:36
http://codepad.org/QN4Noquq
Somebody please tell me what I am doing wrong here. The problem is line 174, which is in list_delete():
free(temp->next);
In Windows the program just stops working correctly (or in this case just terminates since my testcase is very short). In GDB, it gives me the following output when I run the program:
warning: HEAP[list.exe]:
warning: Heap block at 00391060 modified at 0039106C past requested size of 4
I know it's that line because it's in the backtrace and I've stepped through that code many times.
I can't figure out what's wrong with freeing temp->next there. If I print temp->next->data->name just before that line it gives me the expected string, so the memory has to be ok and I'm trying to delete the free the right struct. I just don't understand what the problem is here.
Somebody please tell me what I am doing wrong here. The problem is line 174, which is in list_delete():
free(temp->next);
In Windows the program just stops working correctly (or in this case just terminates since my testcase is very short). In GDB, it gives me the following output when I run the program:
warning: HEAP[list.exe]:
warning: Heap block at 00391060 modified at 0039106C past requested size of 4
I know it's that line because it's in the backtrace and I've stepped through that code many times.
I can't figure out what's wrong with freeing temp->next there. If I print temp->next->data->name just before that line it gives me the expected string, so the memory has to be ok and I'm trying to delete the free the right struct. I just don't understand what the problem is here.