I've been working on the pset6 and implemented the parse and lookup function. I just did something with load function but I am not really much sure if it's correct totally. I haven't implemented the indexes function just yet. Am I going the correct path with the load function?
bool load(FILE* file, BYTE** content, size_t* length)
{
//integer variable for the for loop
int i = 0;
//initiallizing the lenght to 0
*length = 0;
//Checking if the file pointer passed to load is NULL.
if (file == NULL)
{
return false;
}
//Buffer to store every character from 'file'.
char* buffer = malloc(sizeof(BYTE));
if (buffer == NULL)
{
return false;
}
for (char c = fgetc(file); c != EOF; c = fgetc(file))
{
buffer[i] = c;
buffer = realloc(buffer, sizeof(char) + i);
*length = *length + 1;
i++;
}
*content = &buffer[0];
return true;
}