I'm not sure if this is going to make a difference, but free ((args)[...]); 
should just be free(args[..]);

On Dec 26, 2009, at 6:43 PM, Justin wrote:

> Hi, I really can't figure this one out. Please, anyone with an idea please 
> help, here is some code.
> 
> // Get conductivities.
> *k = strtod(args[0], &end);
> *R = strtod(args[1], &end);
> 
> printf("%s\n", args[0]);
> printf("%s\n", args[1]);
> printf("%u\n", &args[0]);
> printf("%u\n", &args[1]);
> 
> // Clear out the args array of pointers.
> for (i = 0; i < numArgs; i++)
> {
> printf("%d\n", i);
> free((args)[i]);
> printf("yo\n");
> }
> 
> Output:
> 0.5
> 0.75
> 4017344
> 4017348
> 0
> yo
> 1
> 
> A little explanation: args is a (char **) and I'm using malloc and realloc to 
> allocate the memory, I've checked that numArgs is equal to 2. Also I know 
> args[1] is properly allocated because the address looks right as well as the 
> fact is that it's printing out 0.75 which is the proper string that should be 
> there. The problem occurs when I try to free args[1] in the for loop as you 
> can see from the output. The error I'm getting says 'The memory could not be 
> "read"' which I understand is windows way of telling me I have a seg fault, 
> but I just can't figure where on this one.
> 
> Any help is appreciated. Thanks ahead of time.
> 
> JBA
> 
> 



[Non-text portions of this message have been removed]



------------------------------------

To unsubscribe, send a blank message to 
<mailto:[email protected]>.Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/c-prog/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/c-prog/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to