This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: malloc()/free() help,please


"Joel Anderson" <joela@umn.edu> 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
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]