delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/12/09/07:09:56

From: "Wormy" <wormy AT technologist DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Problems with MALLOC and FREE
Date: Thu, 9 Dec 1999 12:08:50 +0100
Organization: University of Economics and Business Administration, Vienna, Austria
Lines: 27
Message-ID: <82o2l4$hmr@cantine.wu-wien.ac.at>
NNTP-Posting-Host: 212186012098.11.wu-wien.teleweb.at
X-Newsreader: Microsoft Outlook Express 4.72.3110.1
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

HI!
I wrote a prog that MALLOC's very much memory in the way like that:

char *mem[4096];

....

for (x=0; x<4096; x++)
  if ((mem[x]=(char *)MALLOC(64*sizeof(char)))==NULL)
  {
    DO ERROR CODE
  }

THIS WORKS FINE!

But if, at shutdown, I do

for (x=0; x<4096; x++)
  if (mem[x] != NULL)
    free (mem[x]);

IT HAPPENS... WELL, MORE THAN ONLY SOMETIMES THAT I GET A SIGSEGV!!!!!
WHY IS THAT??? I OFTEN GET SUCH A SIGSEGV IF I TRY TO FREE VERY MUCH MEMORY
PREVIOUSLY MALLOCated with MALLOC...



- Raw text -


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