Closed BloodyWulf closed 7 years ago
I know that. This version is in general really bad coded.
On the matter of malloc(0): The reason is: How much space should be reserved for a dynamic array with size 0? I guess setting the pointer to NULL is better? realloc should (theoretically) deal with it.
Hey there.
I see that you never check the return values of malloc/realloc. Thats pretty bad! You must always check the return value of malloc/realloc. To not check that is realy careless.
malloc:
realloc
You also call malloc a few times with a value of zero. Thats also bad:
webserver.c, lines 289
headers.fields = (header_t*) malloc(0 * sizeof(header_t));
webserver.c, lines 384
server.handles = (handle_t*) malloc(0);
Maybe there are more occurrences of that. You should check that.
You should read also this articles from Ted Unangst: zero size objects it’s hard work printing nothing
Regards