Re: Error freeing memory....



Nick Keighley wrote:

On 15 Mar, 02:33, pete <pfil...@xxxxxxxxxxxxxx> wrote:
Eric Sosman wrote:
On 3/14/2010 1:57 PM, Sheldon wrote:

I have a fairly large program that has a problem that I cannot seem to
solve.
The program runs smoothly but when it tries to free allocated memory
before exiting I get a segmentation fault.
I have checked many times the following:

1. That I have not freed the memory before hand and call free this
way: if(array) free(array);

A note in passing: This makes no difference, because
free(NULL) is legal (and does nothing).

And it also makes no difference because

if(freed_pointer) free(freed_pointer);

is still undefined.

why?

I intended for (freed_pointer) to represent a previously freed pointer.

--
pete
.



Relevant Pages

  • Re: Error freeing memory....
    ... The program runs smoothly but when it tries to free allocated memory ... before exiting I get a segmentation fault. ... I was treating at just an arbitary name ...
    (comp.lang.c)
  • Re: Error freeing memory....
    ... Nick Keighley wrote: ... The program runs smoothly but when it tries to free allocated memory ... before exiting I get a segmentation fault. ...
    (comp.lang.c)
  • Error freeing memory....
    ... The program runs smoothly but when it tries to free allocated memory ... before exiting I get a segmentation fault. ... The arrays are vectors that was allocated with error checking: ... There are no conflicts like a double definition of a variable. ...
    (comp.lang.c)
  • Re: [Full-disclosure] GnuPG fun
    ... gpg: Segmentation fault caught ... ... out of memory while allocating 4294967295 bytes ...
    (Full-Disclosure)
  • Re: Error freeing memory....
    ... Eric Sosman wrote: ... The program runs smoothly but when it tries to free allocated memory ... before exiting I get a segmentation fault. ... A note in passing: ...
    (comp.lang.c)