Just a sample of the Echomail archive
COMPLANC:
[ << oldest | < older | list | newer > | newest >> ]
|  Message 241,247 of 243,097  |
|  Bonita Montero to All  |
|  Re: Nice way of allocating flexible stru  |
|  08 Oct 25 11:23:13  |
 
From: Bonita.Montero@gmail.com
Am 08.10.2025 um 11:09 schrieb Bonita Montero:
> Am 08.10.2025 um 08:35 schrieb Kaz Kylheku:
>> Jonas Lund of https://whizzter.woorlic.org/ mentioned this
>> trick in a HackerNews comment:
>>
>> Given:
>>
>> struct S {
>> // ...
>> T A[];
>> };
>>
>> Don't do this:
>>
>> malloc(offsetof(S, A) + n * sizeof (T));
>>
>> But rather this:
>>
>> malloc(offsetof(S, A[n]));
>>
>> It's easy to forget that the second argument of offsetof is a
>> designator, not simply a member name.
>>
>
> In a real language:
>
> #include
|
[ << oldest | < older | list | newer > | newest >> ]
(c) 1994, bbs@darkrealms.ca