0

I have struggled with the server.c for half a month. Now everything seems OK except for the html page.When I firstly type in the name, it shows correctly.

enter image description here

But the second time,I type in another name-dana, it shows that the memory of the first name is not cleared. enter image description here

And the check50 always returns false,too. enter image description here

Is it because there is something wrong with the load function?

bool load(FILE* file, BYTE** content, size_t* length)
{
    // ensure pipe is open
    if (file == NULL)
    {
        return false;
    }


    // initialize the pointers
    *content = NULL;
    *length = 0;
    char* file_content = NULL;
    // allocate memory on the heap
    file_content = malloc(1);
    if (file_content == NULL) 
    {
        return false; 
    }
    //i for getting the size of content
    int i = 0;
    for (int c = fgetc(file); c != EOF; c = fgetc(file))
    {
        file_content[i] = (char) c;
        i++;
        file_content = (char*) realloc(file_content, sizeof(char)*(i+1));
    }
    //increase size for every loop
    //reallocate memory of file_content
    *content = file_content;
    *length = i;
    return true;
}
3
  • This kind of error is most likely parse()'s fault. You're probably doing something wrong with query. But these two reds on check50 are probably indexes() fault. Commented Dec 5, 2016 at 1:45
  • Thank you very much. The problem literally lies in the indexes() and query. Finally I pass the check50. OH LA LA.
    – Charlotte
    Commented Dec 6, 2016 at 12:29
  • Great! I'll make this comment an answer then, so you can accept it later and let the question rest as closed! Commented Dec 6, 2016 at 12:30

1 Answer 1

0

Answered in comments:

This kind of error is most likely parse()'s fault. You're probably doing something wrong with query.

But these two reds on check50 are probably indexes() fault.

You must log in to answer this question.

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