0

receiving the following error in the program-

corrupted size vs. prev_size

Aborted

it runs fine with small texts such as cat.txt but not with bigger ones such as lalaland.txt

could anyone kindly inform me when/why does this error occur?

tried valgrind too but am unable to understand the problem.

link for code which contains the troublesome function - https://gist.github.com/ayushm2003/dcf761a81ddc955fd09f2385d3ccf428

2

1 Answer 1

1

This char *str = malloc(strlen(word)); is a problem, remember a 3-letter word requires 4 bytes of memory (terminating null byte).

This free(temp); is a huge problem (both of them). It has just obliterated a node in the linked list. That could (likely) be some other node's next. Not to mention, the word may appear in the text again. Program shouldn't free nodes til it's done using them. Which would be when unload is called.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .