delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/10/06:39:05

Date: Thu, 10 Jun 1999 13:36:31 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Dlanor Blytkerchan <dlanor AT dds DOT nl>
cc: djgpp AT delorie DOT com
Subject: re: malloc() problem
In-Reply-To: <v01540b01b3852d011dfb@[145.18.167.138]>
Message-ID: <Pine.SUN.3.91.990610132120.29131A-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Thu, 10 Jun 1999, Dlanor Blytkerchan wrote:

> I downloaded a package containing sources of all kinds of foolish programs.
> I don't recall what it was called, but it was described as "test sources"
> and unpacked into a directory called DJGPP/TESTS.

Oh, that would be djtst202.zip.  It's a test suite for the library 
functions.  The only programs that could be relevant for you in that 
package are those which test malloc, but there are no such programs
in djtst yet.  Anyway, your problem doesn't seem to be a simple one
which would be detected by a general-purpose test program.  It's 
some subtle detail, not a general problem, or so it seems.

> //  if (rc) rc = ((buffer = malloc(sizeof(bufferType))) != NULL); // old
>   if (rc) rc = ((buffer = malloc(34 * 1024)) != NULL); // new

Are you sure that "sizeof(bufferType)" indeed returns 34*1024?  I suggest 
to try to recreate the call to malloc as close as possible to the 
conditions where it fails.  Sometimes adding 1 byte to a request might 
change the effect dramatically, especially if some obscure bugf is 
involved here.

Don't forget that the compiler inserts padding between struct members, so 
it's not always trivial to compute the total length.  sizeof will tell you 
exactly.

> I've "heard" a lot about this Emacs, just not what it's for ;-)
> I'd be interested in taking a look at the source

Feel free to do that, but I don't recommend doing it as an efficient way 
of attacking this problem.  Emacs sources total more than 200,000 lines 
of C, and that's only for the primitives (the rest is in a special 
dialect of Lisp), so reading all of it just to find what does it do 
differently with memory allocation would be a terrible waste of time.

(Needless to say, I didn't write Emacs, I just help to maintain a small 
part of it.)

> Is it available somewhere (on an FTP site)?

     ftp://ftp.gnu.org/gnu/emacs/emacs-20.3.tar.gz

- Raw text -


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