Thread: using free()

  1. #16
    Registered User
    Join Date
    Dec 2001
    No worries
    one fish two fish
    red fish blue fish

  2. #17
    Registered User Engineer's Avatar
    Join Date
    Oct 2001
    Wow, I am impressed!!!

    All this because of something I said...
    1 rule of the Samurai Code: if you have nothing to say, don't say anything at all!

  3. #18
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > so what about some answers regarding my original question please..... thanks

    > but i keep getting a runtime error during the freeing of the elements !
    Since there is nothing wrong with the way you allocate and free, there must be something wrong with the way you use the allocated memory.

    A common mistake is something like this
    n = strlen(string);
    char *p = malloc( n );  // BUG - should be n+1
    strcpy( p, string );
    Memory is corrupted because you copy one more byte than there is allocated space (therefore running into something else - usually some malloc/free control structure).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 12
    Last Post: 06-24-2005, 04:27 PM
  2. Help needed with backtracking
    By sjalesho in forum C Programming
    Replies: 1
    Last Post: 11-09-2003, 06:28 PM
  3. "if you love someone" :D
    By Carlos in forum A Brief History of
    Replies: 12
    Last Post: 10-02-2003, 01:10 AM
  4. SIGABRT upon free()
    By registering in forum C Programming
    Replies: 2
    Last Post: 07-19-2003, 07:52 AM