Thread: Free allocated space

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Bit Fiddler
    Join Date
    Sep 2009
    Posts
    79

    Free allocated space

    I'm calling a function that's allocating space and filling a char array.

    Code:
    char **array;
    size = split(&array, string, delim);
    
    free(array)
    
    int split(char ***trgtArrray, char *string, char delim) {
      [...]
      (*trgtArray) = (char **) malloc(count);
      [...]
    
      return count;
    }
    When I try to free **array it crashes. What am I doing wrong?
    Last edited by Fader_Berg; 10-31-2010 at 07:03 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. lots of freeware
    By major_small in forum General Discussions
    Replies: 60
    Last Post: 02-14-2017, 03:00 AM
  2. Question about Free() and Ptr-Ptr-Int
    By Kehyn in forum C Programming
    Replies: 11
    Last Post: 04-14-2010, 08:37 PM
  3. How to properly free a pointer and its allocated memory
    By yuzhangoscar in forum C Programming
    Replies: 2
    Last Post: 09-16-2008, 06:26 AM
  4. Following CTools
    By EstateMatt in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 10:10 AM
  5. Free store vs. heap
    By CondorMan in forum C++ Programming
    Replies: 1
    Last Post: 08-07-2006, 11:41 AM