Deutsch   English   Français   Italiano  
<vaedct$1ovo2$1@raubtier-asyl.eternal-september.org>

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

Path: ...!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: size_t best practice
Date: Sun, 25 Aug 2024 06:53:49 +0200
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <vaedct$1ovo2$1@raubtier-asyl.eternal-september.org>
References: <VdCcne2MOeshN1z7nZ2dnZfqnPWdnZ2d@brightview.co.uk>
 <vad6el$1fro3$1@raubtier-asyl.eternal-september.org>
 <nnd$3cfad599$31c01852@c35b725b59d8c079>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 25 Aug 2024 06:53:50 +0200 (CEST)
Injection-Info: raubtier-asyl.eternal-september.org; posting-host="3279ca422f8cc154b312f9d64576c044";
	logging-data="1867522"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+RrYjn9e85sMBFLOrWv5GEScK9wJ568y0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:a+oskP3qPvnJ18b6A8LJTgtMPho=
Content-Language: de-DE
In-Reply-To: <nnd$3cfad599$31c01852@c35b725b59d8c079>
Bytes: 1999

Am 25.08.2024 um 06:30 schrieb Sjouke Burry:
> On 24.08.24 19:49, Bonita Montero wrote:
>> Am 18.08.2024 um 10:03 schrieb Mark Summerfield:
>>
>>> void vec_insert(vec* v, size_t index, void* value) {
>>>       if (v->_size == v->_cap) {
>>>           vec_grow(v);
>>>       }
>>>       for (size_t i = v->_size - 1; i >= index; --i) {
>>>           v->_values[i + 1] = v->_values[i];
>>>           if (!i) // if i == 0, --i will wrap!
>>>               break;
>>>       }
>>>       v->_values[index] = value;
>>>       v->_size++;
>>> }
>>
>> Ultra-ugly, better use C++ and std::vector<>::emplace_back()/emplace().
>>
> Ultra stupid. This is a c newsgroup.

Not stupid because in C++ you've got a tenth of the work.