[patch v4] malloc: avoid need for tcache == NULL checks
Florian Weimer
fweimer@redhat.com
Mon Sep 8 05:25:40 GMT 2025
* DJ Delorie:
> Florian Weimer <fweimer@redhat.com> writes:
>>> + if (av)
>>> + tcache = (tcache_perthread_struct *) _int_malloc (av, request2size (bytes));
>>
>> I think this is too long.
>
> It's 80 chars, tweaked.
>
>>> + else
>>> + tcache = (tcache_perthread_struct *) __libc_malloc2 (bytes);
>>>
>>> - if (tcache != NULL)
>>> + if (tcache == NULL)
>>> + {
>>> + /* If the allocation failed, don't try again. */
>>> + tcache_set_disabled ();
>>> + }
>>> + else
>>
>> Already set above.
>
> No! Setting tcache to the result of malloc undoes that and either
> leaves it active (non NULL) or NULL - and a NULL tcache is not the same
> as tcache_set_disabled, which sets tcache to a known pointer.
Thanks for the clarification.
Florian
More information about the Libc-alpha
mailing list