X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f Message-ID: <20020412182911.49752.qmail@web9904.mail.yahoo.com> Date: Fri, 12 Apr 2002 11:29:11 -0700 (PDT) From: Lets Go Canes Subject: Re: New DJGPP hogs memory (was: I need help) To: djgpp AT delorie DOT com In-Reply-To: <5.0.2.1.0.20020411161942.00bd1eb0@pop.mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk Hello all. I realize this was intended as a test program, but on the assumption that it is based on a real program, I thought I would make a few comments/suggestions. --- "José_L._Sánchez_Garrido" wrote: > -------------------cut here----------------------------------- > #include > #include > > typedef struct { > char af[10]; > char name[10]; You are going to allocate 2,000,000 of these structures, which will be ~40MB (plus overhead). Unless you know that the data being placed in .af and .name are going to use more than 5 or characters, it *might* be worth changing these to pointers. It all depends on the data. > > } record; > > record **dt, *d; > > int main (void) { > > int count; > > for(count=0; count<200000L; count++){ > dt=(record **)realloc(dt, (count+1)*sizeof(record *)); > d=dt[count]; > d=(record *)calloc(10, sizeof(record)); > } Surely this should be something like: #define LIMIT 200000L dt=(record **)alloc(dt, LIMIT*sizeof(record *)); for (count=0; count return(0); > } > ------------------cut here--------------------------------------- ===== -------------- Lets Go Canes! __________________________________________________ Do You Yahoo!? Yahoo! Tax Center - online filing with TurboTax http://taxes.yahoo.com/