Article View: comp.lang.c.moderated
Article #2481Re: void* type
From: Lawrence Kirby
Date: Wed, 03 Apr 1996 13:12
Date: Wed, 03 Apr 1996 13:12
30 lines
1950 bytes
1950 bytes
In article <4jr71q$h66@solutions.solon.com> stanr@tiac.net "Stan Ryckman" writes: >>Better yet: unless memory is really tight, have it double the size. >>This will set a fairly reasonable upper bound on the number of reallocs >>you will have to do. > >Not necessarily better. If you're at 40% of your machine's >physical memory, doubling could be a real performance killer. >With my suggestion (add some amount to the size and realloc) >you will rapidly reach the max if the sizes arrive "randomly". >Any strategy here would involve knowing something about your >target system, I think, but probably something like >11*(sz+C)/10 where C is much less than the physical memory >on your computer would be safer (even a few hundred realloc calls >rather than a dozen or so shouldn't matter, if the calls >occur with an "unlucky" distribution of sz values). My normal approach to this is to start with some reasonable non-zero value and use: sz += sz / X; where X is typically 2, 4 or 8 depending on the prevailing conditions (small sop to efficiency). -- ----------------------------------------- Lawrence Kirby | fred@genesis.demon.co.uk Wilts, England | 70734.126@compuserve.com -----------------------------------------
Technical Details
Message-ID:
<4jttfc$3lr@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailReferences:
<4iepre$ag7@solutions.solon.com> <4jckqc$a5o@solutions.solon.com> <4jibl5$89u@solutions.solon.com> <4jol6e$1rr@solutions.solon.com> <4jr71q$h66@solutions.solon.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: Lawrence Kirby <fred@genesis.demon.co.uk> Newsgroups: comp.lang.c.moderated Subject: Re: void* type Date: 3 Apr 1996 07:12:12 -0600 Organization: none Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4jttfc$3lr@solutions.solon.com> References: <4iepre$ag7@solutions.solon.com> <4jckqc$a5o@solutions.solon.com> <4jibl5$89u@solutions.solon.com> <4jol6e$1rr@solutions.solon.com> <4jr71q$h66@solutions.solon.com> Reply-To: fred@genesis.demon.co.uk NNTP-Posting-Host: solutions.solon.com X-NNTP-Posting-Host: genesis.demon.co.uk X-Newsreader: Demon Internet Simple News v1.27 X-Mail2News-Path: genesis.demon.co.uk