freeing of char**

From: gregg (greggory_at_netJUSTSAYNOcourrier.com)
Date: 01/22/04


Date: Thu, 22 Jan 2004 18:24:19 +0100

Hello all,

I have a char **, which points to a number of strings (char*).
When comes the moment to free it, i have to free all the (char*) inside.
Yet when i do this:

int i;

for ( i=0; *(myChar+i) != NULL; i++ )
        free (*(myChar+i)); /* to free the (char*) inside
free(myChar);

well, on execution the system says 'junk pointer, too low to make sense'
(and the pointers aren't freed)

of course, when i write (*(myChar+i) = NULL), it's all okay
(except the memory hasn't been freed ?!)

so how should i free the (char**) to make it work, and also be clean ?

thx
gregg



Relevant Pages

  • Re: What if black holes are just a glitch in the matrix?
    ... Computer programs are deterministic... ... char data; ... int f{ ... of course converted into a deterministic machine during execution, ...
    (sci.physics)
  • Re: freeing of char**
    ... gregg wrote: ... > When comes the moment to free it, i have to free all the (char*) ... > int i; ... > well, on execution the system says 'junk pointer, too low to ...
    (comp.lang.c)
  • variadic functions
    ... printf ("execution was here"); ... int main ... int printf(const char *, ...); ...
    (comp.lang.c)
  • Re: Benchmark results (Re: Storage of char in 64 bit machine)
    ... CurEqual(char *c1, char *c2) ... int ceq ... strings this is the MOST LIKELY result. ... Don't forget that execution speed is data dependant so you ...
    (comp.lang.c)
  • Re: freeing of char**
    ... > When comes the moment to free it, i have to free all the (char*) inside. ... > int i; ... > well, on execution the system says 'junk pointer, too low to make sense' ... whether you've done any allocations or not. ...
    (comp.lang.c)