Hello I am going through the code for pset6 and I cannot figure out what this fields variable is for? They create and init it even test if it is 0 but it is never changed. I am posting a small part of the request function but it is the only part of all the code that it is used in. I just do not understand what it is for. Did they forget to use it or am I missing something. Thanks
// count fields in message
int fields = 0;
haystack = needle + 2; //move to next byte after '\r\n'
while (*haystack != '\0')
{
// look for CRLF
needle = strstr(haystack, "\r\n"); //search for this in what is left of haystack [if found there is another field]
if (needle == NULL)
{
break;
}
// ensure field is no longer than LimitRequestFieldSize
if (needle - haystack + 2 > LimitRequestFieldSize) //(the total size including '\r\n') > MAX FIELD SIZE
{
break;
}
// look beyond CRLF
haystack = needle + 2;
}
// if we didn't get to end of message, we must have erred
if (*haystack != '\0')
{
break;
}
// ensure message has no more than LimitRequestFields
if (fields > LimitRequestFields) // never going to be true because fields is never used
{
break;
}