I am getting these check50 errors can someone tell me in easy english what they are and why they are caused and the possible solution for it and if my approach to load and indexes functions are correct or not
load function is as follows
bool load(FILE* file, BYTE** content, size_t* length)
{
// TODO
if(file == NULL)
{
return false;
}
// needed when dereferenceing the data to the pointer content so
// that the next buffer is stored at *content + counter
int counter = 0;
int buffer = BYTES;
//creating the memory block directly at content
*content = malloc(buffer);
BYTE buff;
while(fread(&buff, sizeof(BYTE), 1, file) == 1)
{
//if 512 blocks have been read then add another 512 blocks to memory
if(counter == buffer)
{
buffer = buffer + counter;
*content = realloc(*content, buffer);
}
*(*content + counter) = buff;
counter++;
}
*length = counter;
return true;
}
and indexeses is as follows
char* indexes(const char* path)
{
// TODO
if (path != NULL)
{
FILE* infile= NULL;
// to create enough space to add /index.html or index.php in the path
char* directory = malloc(strlen(path) + 13);
//copying path to directory
strcpy(directory, path);
//to see if index.php is there
infile = fopen("index.php", "r");
// that means index.php is there
if(infile != NULL)
{
// adding /index.php in directory's end
strcat(directory, "/index.php");
//storing the address of directory to path
//*path = &directory;
return directory;
}
else
{
fclose(infile);
infile = fopen("index.html", "r");
if(infile != NULL)
{
// adding /index.html in directory's end
strcat(directory, "/index.html");
//storing the address of directory to path
//*path = &directory;
return directory;
}
}
free(directory);
fclose(infile);
}
return NULL;
}
I managed to get all green faces in the first check50 test.