delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/10/05/20:00:31

From: Damian Yerrick <Bullcr_pd_yerrick AT hotmail DOT comRemoveBullcr_p>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: get the amount of physical memory
Organization: Pin Eight Software http://pineight.8m.com/
Message-ID: <h8imtsgmgsjsbvctpnvvbplmkqa6n964fa@4ax.com>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1001003142803 DOT 12455B-100000 AT is> <39DA1E51 DOT D0C53931 AT cyberoptics DOT com>
X-Newsreader: Forte Agent 1.7/32.534
MIME-Version: 1.0
Lines: 31
X-Trace: /bdhN45vQRaSJ8J44ihIZjbbmInjNNGnugWw+QIBWhdR+oxwbZkJNr5ctsNCl6c8PveVzBmPhxiH!Rn7jieKyF+Q8O9A+xV5UONo+30+oHtzWWGlCyaTSRhktMYhAZfwN17SAwkfiGPaoi/KhJBUsCsDu!6q3MRA==
X-Complaints-To: abuse AT gte DOT net
X-Abuse-Info: Please be sure to forward a copy of ALL headers
X-Abuse-Info: Otherwise we will be unable to process your complaint properly
NNTP-Posting-Date: Wed, 04 Oct 2000 15:16:09 GMT
Distribution: world
Date: Wed, 04 Oct 2000 15:16:09 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Tue, 03 Oct 2000 12:58:41 -0500, Eric Rudd <rudd AT cyberoptics DOT com>
wrote:

>For instance, a routine that creates an array of pointers, each
>element pointing to the beginning of a line in a text file

A standard text editor data structure.  Go on.

>can't predict how much space it needs for the array until it
>has counted the number of lines in the file.  This means either
> o making two passes over the file (slow)

Not if the file fits in core.

> o doing a lot of realloc calls along the way (also slow)

If you only realloc() to _double_ the size of the vector when
necessary, it's not nearly as slow.

> o reserving space at the outset for the largest array one might
>   need (fast and expedient).

You could also use a linked list or a binary tree if you needed it.

-- 
<O
( \   GNOME vs. KDE: the game!
 X    http://pineight.8m.com/nes.htm

This is McAfee VirusScan. Add these two lines to your signature to
prevent the spread of signature viruses.  http://www.mcafee.com/

- Raw text -


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