Article View: comp.lang.c
Article #1855Re: C and its pesent 'ancestos'
From: fir
Date: Thu, 26 Nov 2026 10:21
Date: Thu, 26 Nov 2026 10:21
147 lines
6203 bytes
6203 bytes
Bonita Montero pisze:
> Am 26.11.2026 um 11:02 schrieb fir:
>
>> btw, no one understand the neccsity of
>>
>> int tab[100];
>> tab.length*=3;
>
> In C++ you dont' have to do that. In C++ you simply use emplace_back
> and let the templated runtime to the growing of the capacity. No need
> to handle with pointers yourself. And accessing the contents of a
> container is bounds-checked while debugging (optional with libstdc++,
> default with VC++).
>
>> classic c arrays but bused on realloc internally and thus being able
>> to be resized freely (i already made tham in my own compiler (unfinished)
>> ) you just emit calls to reallock when you meed those reallocking
>> cyntaxes
>
> In C++ the contained values of a vector could have an arbitrary type and
> if the values are moveable a resize is very cheap. Doing this in C is a
> magnitude more work.
>
what magnitudes here you also can have
tabbit tab[20];
if rabbit is a structure (if we talk on just c w ith resizable arrays, or
hipermodule if we move on more elaborate c extansions)
you cal reallock internally (in c runtime) if you wnat to resize
tab.length+=80;
tab.length=tab.length+ 80;
tab.length*=3; //and so on
so its cost of realock
if you want cheap use flags enabled on records and find empty ones and
only resize if its full
(this with enable flag and eventually resize i do in my own C
like for example (dirty code is i got no time to polish)
inline int countOcupationInBag()
{
int counter=0;
for(int i=0;i<bag_max;i++) if(bag[i].enabled) counter++;
return counter;
}
inline void ResizeBag(int new_size)
{
// printf("ResizeBag: bag=%p old=%d new=%d\n",(void*)bag,bag_max,new_size);
int old_size=bag_max;
Object3D *new_bag=(Object3D*)realloc(bag,new_size*sizeof(Object3D));
if(!new_bag) return;
bag=new_bag;
for(int i=old_size;i<new_size;i++) memset(&bag[i],0,sizeof(Object3D));
bag_max=new_size;
if(bag_i>=bag_max) bag_i=0;
}
inline int FindEmptySlotInBag()
{
if(bag_max==0) ResizeBag(3000);
if(bag_max==0) return -1;
if(bag_i>=bag_max) bag_i=0;
for(int i=0;i<bag_max;i++)
{
if(!bag[bag_i].enabled) return bag_i;
bag_i++;
if(bag_i>=bag_max) bag_i=0;
}
int old_size=bag_max;
ResizeBag(bag_max*2);
if(bag_max==old_size) return -1;
return FindEmptySlotInBag();
}
but if you got this builtin in c its obviously unpararalelably better
what in c++ crap beats that ? magnitudes?
(sorri i must go out of hause so i will be later here)
>> void EmitResizeFromEax(chunk name)
>> {
>> FlushOutAsm("\n push eax" );
>>
>> FlushOutAsm("\n push eax" );
>> FlushOutAsmChunkPE("\n push (", name, ") ");
>> FlushOutAsm("\n call (\"msvcrt.dll\"->realloc)");
>> FlushOutAsmChunkPE("\n mov (", name, ") eax ");
>> FlushOutAsm("\n pop edx");
>> FlushOutAsm("\n pop edx");
>> FlushOutAsmChunkPE("\n mov (", name, ") eax ");
>> FlushOutAsm("\n pop eax");
>> FlushOutAsmChunkPE("\n mov (", name, "_size) eax ");
>>
>> if(emit_basic_debug_info_for_initial_reallocks)
>> {
>> // FlushOutAsm("\n mov eax (__realloc_sum_counter) ");
>> // FlushOutAsm("\n add eax %d", size);
>> // FlushOutAsm("\n mov (__realloc_sum_counter) eax");
>> //
>> //
>> // FlushOutAsm("\n push %d ", size);
>> // FlushOutAsm("\n push __reallocked_str_label");
>> // FlushOutAsm("\n call (\"msvcrt.dll\"->printf)");
>> // FlushOutAsm("\n pop edx ");
>> // FlushOutAsm("\n pop edx ");
>> }
>>
>> }
>
> Sick, totally sick !
>
>> instead of insane bulshit of c++ containers?
>
> They're much easier to handle.
>
> You don't trust into abstractions and you would be overburdened with
> a language like C++ or Rust. These abstractions that do the same thing
> you do manually in C. Instread you want to flip every bit yourself in
> C. This leads to more and less readable code.
>
Technical Details
Message-ID:
<11e9171$ivdo$1@dont-email.me>Path:
mbox-mo1.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<11dup6q$v4j9$1@dont-email.me> <11e0kde$1jpvu$1@dont-email.me> <11e0r13$1lqm6$1@dont-email.me> <11e0uc0$1mtpv$1@raubtier-asyl.eternal-september.org> <11e7fj4$37l9$1@dont-email.me> <11e8oro$ft4l$1@raubtier-asyl.eternal-september.org> <11e8stp$hajr$1@dont-email.me> <11e8ti0$hhqa$1@dont-email.me> <11e8v24$i2mc$2@raubtier-asyl.eternal-september.org> <11e9045$ihk3$1@dont-email.me> <11e90j7$io87$1@raubtier-asyl.eternal-september.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: fir <profesor.fir@gmail.com> Newsgroups: comp.lang.c Subject: Re: C and its pesent 'ancestos' Date: Thu, 26 Nov 2026 11:21:21 +0100 Organization: A noiseless patient Spider Lines: 147 Message-ID: <11e9171$ivdo$1@dont-email.me> References: <11dup6q$v4j9$1@dont-email.me> <11e0kde$1jpvu$1@dont-email.me> <11e0r13$1lqm6$1@dont-email.me> <11e0uc0$1mtpv$1@raubtier-asyl.eternal-september.org> <11e7fj4$37l9$1@dont-email.me> <11e8oro$ft4l$1@raubtier-asyl.eternal-september.org> <11e8stp$hajr$1@dont-email.me> <11e8ti0$hhqa$1@dont-email.me> <11e8v24$i2mc$2@raubtier-asyl.eternal-september.org> <11e9045$ihk3$1@dont-email.me> <11e90j7$io87$1@raubtier-asyl.eternal-september.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Thu, 26 Nov 2026 10:21:22 +0000 (UTC) Injection-Info: dont-email.me; logging-data="622008"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19dQ4xuiyhgJmgIEEkxEsQWQ+o+nerA2IU="; posting-host="3e78a52f82bf0b5f9f467f865e9c0f0c" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0 SeaMonkey/2.53.24 Cancel-Lock: sha1:r952IeoXiwaky/WwaFbt6ktntF0= sha256:2YZNGZOee+mAeT8f4d8HhioELLqzK2cpcn88a6qJCjM= sha1:27gvAr/gRsXDxDWe+I5hQHSwgbQ= sha256:rT+LT9JfCCj4djyXdBftEMpbZ8AM4VzYoeAK/wWdL5c= In-Reply-To: <11e90j7$io87$1@raubtier-asyl.eternal-september.org>