2009-08-24, 05:04 AM
Is it considered bad practice to do this?
In other words, is it bad practice to use a pointer twice as I've done above? If so, what's the correct thing to do?
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
unsigned char* fileContents;
//Following function returns a memory location of heap-allocated data
fileContents = GetFileContents("foo.txt");
free(fileContents);
fileContents = GetFileContents("bar.txt");
free(fileContents);
return 0;
}In other words, is it bad practice to use a pointer twice as I've done above? If so, what's the correct thing to do?


tring instead of raw dynamic arrays whenever possible. Manual memory management is error-prone.