[prog] free() troubles, pointer arrays

dominik.schramm at gmxpro.net dominik.schramm at gmxpro.net
Thu Mar 18 01:13:14 EST 2004


ed orphan <millward at Ms.UManitoba.CA> writes:

> [...]
>            free( * main_ptr[i] );
> [...]
>   The executable runs just fine, except the compiler gives a warning:
> "warning: passing arg1 of 'free' makes pointer from integer
>   without a cast"

The prototype of free is 
  void free(void*)

You're completely dereferencing main_ptr -- once with * and once with
[] --, which leaves a char (an integer subtype).
That's where the warning comes from.

I don't know how main_ptr "looks like", but I'd say
  free(main_ptr[i]) 
does what you want.
I'm not sure if anything is actually freed when you write free(*main_ptr[i]).

dominik



More information about the Programming mailing list