Subject: Re: malloc()/free() help,please
From: [email-masked] (Mumit Khan)

25 Nov 1998 10:58:07 -0800
Message-ID: <[email-masked]>
References: <[email-masked]>
To: "Joel Anderson" <[email-masked]>
Cc: [email-masked]

"Joel Anderson" <[email-masked]> writes:
> Overall I really,really like this package!  (OTOH plain text man pages, or a 
> simple man tool would REALLY be good....)   But I have a small problem.  A si
> mple tool I wrote that works find on Unix is blowing up in free():

Usually a sign of buggy code more often than anything else. There are very
good memory debuggers that a programmer should use before looking further.

>    
> Any thoughts:

A few.

>     for (x=0;x<wcount;x++){
>         free(voc[x][ENG]);
>         free(voc[x][GAL]);
>     }

Are these uninitialized the first time through? If so, you can't simply 
"free" the pointers.

>             /*  printf ("G: >%s< / E: >%s<\n",g,e);*/
>             ecop = (char*)malloc(strlen(e));
>             gcop = (char*)malloc(strlen(g));

This is a good candidate for for memory corruption. If you don't know why, 
then it's a good time to learn the basics of C character string routines 
and memory allocation.

Regards,
Mumit

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".