From: Damian Yerrick Newsgroups: comp.os.msdos.djgpp Subject: Re: get the amount of physical memory Organization: Pin Eight Software http://pineight.8m.com/ Message-ID: References: <39DA1E51 DOT D0C53931 AT cyberoptics DOT com> X-Newsreader: Forte Agent 1.7/32.534 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 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. --