Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <v5bv37$vejk$1@raubtier-asyl.eternal-september.org>
Deutsch   English   Français   Italiano  
<v5bv37$vejk$1@raubtier-asyl.eternal-september.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
From: Bonita Montero <Bonita.Montero@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: realloc() - frequency, conditions, or experiences about
 relocation?
Date: Mon, 24 Jun 2024 16:16:07 +0200
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <v5bv37$vejk$1@raubtier-asyl.eternal-september.org>
References: <v4ojs8$gvji$1@dont-email.me>
 <v4ov8h$j2q2$1@raubtier-asyl.eternal-september.org>
 <v52270$2nli8$1@dont-email.me>
 <v54jac$3a4p2$1@raubtier-asyl.eternal-september.org>
 <v5bbd3$rhao$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 24 Jun 2024 16:16:07 +0200 (CEST)
Injection-Info: raubtier-asyl.eternal-september.org; posting-host="25e5eda89458a83976f4ab5b7ad682c9";
	logging-data="1030772"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19F6+Pp4/qLdNBTYD6cT4nU1oZfo7oGVkM="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:PHfZoQZ7MtSXM8DpMEiqWMfdaf8=
Content-Language: de-DE
In-Reply-To: <v5bbd3$rhao$2@dont-email.me>
Bytes: 2222

Am 24.06.2024 um 10:40 schrieb Lawrence D'Oliveiro:

> On Fri, 21 Jun 2024 21:12:12 +0200, Bonita Montero wrote:

>> Usually you don't resize the block with a few bytes ...

> The usual way I use realloc is to maintain separate counts of the number
> of array elements I have allocated, and the number I am actually using. A
> realloc call is only needed when the latter hits the former. Every time I
> call realloc, I will extend by some minimum number of array elements (e.g.
> 128), roughly comparable to the sort of array size I typically end up
> with.
> And then when the structure is complete, I do a final realloc call to
> shrink it down so the size is actually that used. Is it safe to assume
> such a call will never fail? Hmm ...

In C++ you dont't have to think about that. Do an emplace_back and the
capacity() doubles with libstdc++ and libc++ if the vevtor becomes full.