Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Programming "What-if"?
#1
Is it considered bad practice to do this?

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?
Reply


Messages In This Thread
Programming "What-if"? - by Fiel - 2009-08-24, 05:04 AM
Programming "What-if"? - by Tikey - 2009-08-24, 06:00 AM
Programming "What-if"? - by parshimers - 2009-08-24, 06:08 AM
Programming "What-if"? - by JoeTang - 2009-08-24, 06:55 AM
Programming "What-if"? - by Spaz - 2009-08-24, 12:34 PM
Programming "What-if"? - by GummyBear - 2009-08-24, 08:26 PM
Programming "What-if"? - by Nikkey - 2009-08-25, 03:45 AM
Programming "What-if"? - by JoeTang - 2009-08-25, 03:46 AM
Programming "What-if"? - by Fiel - 2009-08-25, 01:50 PM
Programming "What-if"? - by GummyBear - 2009-08-25, 08:32 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)