Thread: freeing memory

  1. #1
    Registered User
    Join Date
    Mar 2007

    freeing memory

    Hi there!

    I want to know how could I free some memory reserved in a function. I have de function like this:

    char *functionname(parametres){
        line = calloc (100,sizeof(char));
        return line;}
    And I want to free that line, I think freeing line in the programe doesn't work. Could anyone help me?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    char *getstuff( size_t s )
        char *c = malloc ( s ? s : 1 );
        return c;
    c = getstuff( 1000 );
    if( c )
        free( c );
    What part can't your figure out?

    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. memory freeing function
    By johndoe in forum C Programming
    Replies: 4
    Last Post: 02-17-2006, 02:08 AM
  2. Freeing memory for non-pointer variables
    By SuperGodAntMan in forum C++ Programming
    Replies: 7
    Last Post: 02-11-2006, 01:30 AM
  3. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  4. memory allocation and freeing
    By Jase in forum Linux Programming
    Replies: 1
    Last Post: 05-25-2003, 06:26 AM
  5. freeing memory
    By mart_man00 in forum C Programming
    Replies: 1
    Last Post: 04-27-2003, 08:51 PM