0
也許有人可以幫助我。在我的項目中,我正在使用具有動態分配的鏈接列表。我不知道爲什麼,但它只是不工作:(爲什麼我在這裏得到一個SIGABRT(動態分配)?
void insertLast (TList *list, wchar_t *string) {
TWord *newWord;
if ((newWord = malloc (sizeof(TWord))) == NULL)
exit (EXIT_FAILURE);
newWord->prev = list->tail;
newWord->next = NULL;
newWord->word = malloc(wcslen(string) * sizeof(wchar_t));
wcscpy(newWord->word, string);
if (list->tail != NULL) {
list->tail->next = newWord;
} else {
list->head = newWord;
}
list->tail = newWord;
}
當我嘗試編譯,我只是看到
lab: malloc.c:3096: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char  &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.
中止
也許有人可以告訴我爲什麼有這樣的煩惱謝謝:)