delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/11/25/10:58:07

From: khan AT xraylith DOT wisc DOT edu (Mumit Khan)
Subject: Re: malloc()/free() help,please
25 Nov 1998 10:58:07 -0800 :
Message-ID: <199811250006.SAA19526.cygnus.gnu-win32@modi.xraylith.wisc.edu>
References: <19981123185217 DOT 19555 DOT qmail AT findmail DOT com>
To: "Joel Anderson" <joela AT umn DOT edu>
Cc: gnu-win32 AT cygnus DOT com

"Joel Anderson" <joela AT umn DOT 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 AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019