[PATCH] malloc: Use current (C11-style) atomics for fastbin access

Florian Weimer fweimer@redhat.com
Tue Nov 13 09:34:00 GMT 2018


* DJ Delorie:

> Florian Weimer <fweimer@redhat.com> writes:
>> 	* malloc/malloc.c (fastbin_push_entry): New function.
>> 	(fastbin_pop_entry): Likewise.  Replaces REMOVE_FB.
>> 	(REMOVE_FB): Remove macro.
>> 	(_int_malloc): Use fastbin_pop_entry and reindent.
>> 	(_int_free): Use fastbin_push_entry.
>> 	(malloc_consolidate): Use atomic_exchange_acquire.
>
> All good with one minor nit...
>
>> +	if (head == NULL)
>> +	  return NULL;
>> +	else
>> +	  tail = head->fd;
>
> This "else" is superfluous.  You can just have the tail = head->fd;
> statement after the "return NULL;".  I think putting it in an "else"
> makes the (false) claim that it might have been executed otherwise.

Actually, it's not, due to the surrounding do-while.  I'll remove the
else and add braces, though.

Thanks,
Florian



More information about the Libc-alpha mailing list