[LEDE-DEV] [PATCH] libubox: Fix calloc_a() to return mem aligned pointers
Ted Hess
thess at kitschensync.net
Fri Feb 24 07:15:01 PST 2017
-----Original Message-----
From: Felix Fietkau
Sent: Friday, February 24, 2017 3:39 AM
To: Ted Hess ; Yousong Zhou ; lede-dev
Subject: Re: [LEDE-DEV] [PATCH] libubox: Fix calloc_a() to return mem aligned pointers
On 2017-02-24 03:37, Ted Hess wrote:
>> Yousong -
>>
>> As a side note to your side note - If you examine the actual
>> mechanics of the allocation, the memory block is indeed size aligned to
>> (4*sizeof(size_t)), but the actual pointer returned is offset of
>> (2*sizeof(size_t)) within the block. As in CHUNK_TO_MEM...
>I think that for calloc_a, using 2*sizeof(size_t) is probably overkill;
>it would be 64 bit on 32 bit architectures and 128 bit on 64 bit
>architectures.
>
>Using sizeof(size_t) should be enough:
Agree - If no other objections, I'll push the fix directly.
/ted
More information about the Lede-dev
mailing list