bool load(FILE* file, BYTE** content, size_t* length)


char* data = malloc(sizeof(BYTE));
int i = 0;

while ((data[i] = fgetc(file)) != EOF)
    data = realloc(data, (sizeof(BYTE) * i) );

*content = data;                   //store address of memory in *content
*length = i;                       //store length of memory in *length


return true;


I'm having problems with server.c and wanted to see if it's because of my load function implementation. Any help would be appreciated.


One problem is here free(data);. You told *content to point to the address holding data, then free "destroys" that memory.

  • So when can I free this memory?
    – user34304
    Feb 17 '17 at 15:57
  • You don't. content will be freed in main around line 1127. Feb 17 '17 at 16:43

You must log in to answer this question.

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