ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/04/12/13:45:41

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
Message-ID: <3CB71962.1D21ED00@yahoo.com>
From: CBFalconer <cbfalconer AT yahoo DOT com>
Organization: Ched Research
X-Mailer: Mozilla 4.75 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: New DJGPP hogs memory (was: I need help)
References: <5 DOT 0 DOT 2 DOT 1 DOT 0 DOT 20020410122845 DOT 00bcbbd8 AT pop DOT mail DOT yahoo DOT com>
<5 DOT 0 DOT 2 DOT 1 DOT 0 DOT 20020410122845 DOT 00bcbbd8 AT pop DOT mail DOT yahoo DOT com> <5 DOT 0 DOT 2 DOT 1 DOT 0 DOT 20020411161942 DOT 00bd1eb0 AT pop DOT mail DOT yahoo DOT com> <2593-Fri12Apr2002115014+0300-eliz AT is DOT elta DOT co DOT il> <3CB6C8FA DOT 45A31BB7 AT yahoo DOT com>
Lines: 83
Date: Fri, 12 Apr 2002 17:41:22 GMT
NNTP-Posting-Host: 12.90.171.93
X-Complaints-To: abuse AT worldnet DOT att DOT net
X-Trace: bgtnsc05-news.ops.worldnet.att.net 1018633282 12.90.171.93 (Fri, 12 Apr 2002 17:41:22 GMT)
NNTP-Posting-Date: Fri, 12 Apr 2002 17:41:22 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

CBFalconer wrote:
> 
> Eli Zaretskii wrote:
> >
... snip ...
> >
> > My recommendation is to modify the algorithm to do a better
> > allocation.  If you cannot do that for some reason, you can find the
> > old implementation of malloc in djlsr203.zip, file name
> > src/libc/ansi/stdlib/fmalloc.c; link it with your program, and you
> > will get the old behavior.
> 
> He might also try my suggested new malloc package for DJGPP, which
> I have mounted at:
> 
>    <http://cbfalconer.home.att.net/download/nmalloc.zip>
> 
> which, among other things, goes to some pains to minimize the
> realloc work.  I have heard nothing back on it from anyone, either
> good or bad.

I just took this thing to experiment with, and get the following
anomaly:

.................
[1] c:\c\malloc>gcc -o evilalgo.o evilalgo.c

[1] c:\c\malloc>gcc -o evilalgo.exe evilalgo.o
evilalgo.o(.text+0x1f8):crt0.s: multiple definition of `__exit'
c:/djgpp/lib/crt0.o(.text+0x1f0):crt0.s: first defined here
evilalgo.o(.text+0x2da):crt0.s: multiple definition of `__sbrk'
c:/djgpp/lib/crt0.o(.text+0x2d2):crt0.s: first defined here
evilalgo.o(.text+0x4c4):crt0.s: multiple definition of
`_crt0_init_mcount'
c:/djgpp/lib/crt0.o(.text+0x4bc):crt0.s: first defined here
evilalgo.o(.text+0x2f8):crt0.s: multiple definition of `__brk'
c:/djgpp/lib/crt0.o(.text+0x2f0):crt0.s: first defined here
evilalgo.o(.text+0x8):crt0.s: multiple definition of `start'
c:/djgpp/lib/crt0.o(.text+0x0):crt0.s: first defined here
collect2: ld returned 1 exit status
...................

while "gcc evilalgo.c" works fine, generating file a.  (NOTE: gcc
works through an alias here, imposing -W -Wall -ansi -pedantic
-gstabs+)

While I look for a reason, does anybody know of any?  My malloc.o
is in the directory, but has not been linked (yet).

The slightly revised source follows:

> /* From djgpp mail list - an evil algorithm */
> #include <stdio.h>
> #include <stdlib.h>
> 
> typedef struct {
>    char af[10];
>    char name[10];
> } record;
> 
> record **dt, *d;
> 
> int main(int argc, char ** argv)
> {
>    unsigned long n = 1000;  /* was 200000L */
>    unsigned int  count;
> 
>    if (argc > 1) n = strtoul(argv[1], NULL, 10);
> 
>    for (count = 0; count < n; count++){
>       dt = (record **)realloc(dt, (count + 1) * sizeof(record *));
>       d = dt[count];
>       d = (record *)calloc(10, sizeof(record));
>       if (!(count & 0xfff)) putc('*', stderr);
>    }
>    return(0);
> } /* evilalgo */

-- 
Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT worldnet DOT att DOT net)
   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>  USE worldnet address!

- Raw text -


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