Path: ...!feeds.phibee-telecom.net!3.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Anton Shepelev Newsgroups: comp.lang.c Subject: Re: realloc() - frequency, conditions, or experiences about relocation? Date: Mon, 17 Jun 2024 18:10:34 +0300 Organization: A noiseless patient Spider Lines: 34 Message-ID: <20240617181034.74fb4cca1f4a9a3ea032825e@g{oogle}mail.com> References: <875xu8vsen.fsf@bsb.me.uk> <87zfrjvqp6.fsf@bsb.me.uk> <87tthrvdtg.fsf@bsb.me.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Injection-Date: Mon, 17 Jun 2024 17:10:35 +0200 (CEST) Injection-Info: dont-email.me; posting-host="e4efe3e0e0736d482d811e40a75979fd"; logging-data="765209"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ptEGIl30xzR/Af4nLwO8MbpdaoWXCw1U=" Cancel-Lock: sha1:dK8VWqCndljAy7vcvU9jbT5fx+Y= X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Bytes: 2561 Ben Bacarisse to Malcolm McLean: > > We have a continuously growing buffer, and we want the > > best strategy for reallocations as the stream of > > characters comes at us. So, given we now how many > > characters have arrived, can we predict how many will > > arrive, and therefore ask for the best amount when we > > reallocate, so that we neither make too many > > reallocation (reallocate on every byte received) or ask > > for too much (demand SIZE_MAX memory when the first byte > > is received).? > > Obviously not, or we'd use the prediction. Not so obvious to me, for the exponential algorithm may be the best when the distribution of buffer size is /not/ known, whereas Malcolm is interested in the cases when we know it. > > Your strategy for avoiding these extremes is exponential > > growth. > > It's odd to call it mine. It's very widely know and used. > "The one I mentioned" might be less confusing description. I think it is a modern English idiom, which I dislike as well. StackOverflow is full of questions starting like: "How do you do this?" and "How do I do that?" They are informal ways of the more literary "How does one do this?" or "What is the way to do that?" -- () ascii ribbon campaign -- against html e-mail /\ www.asciiribbon.org -- against proprietary attachments