[PATCH] libiberty: Make `objalloc_free' `free'-like WRT null pointer
Jan Beulich
jbeulich@suse.com
Thu Jan 8 07:43:27 GMT 2026
On 07.01.2026 23:18, Andrew Pinski wrote:
> On Wed, Jan 7, 2026 at 1:31 AM Maciej W. Rozycki <macro@redhat.com> wrote:
>> --- binutils-gdb.orig/libiberty/objalloc.c
>> +++ binutils-gdb/libiberty/objalloc.c
>> @@ -178,7 +178,7 @@ objalloc_free (struct objalloc *o)
>> {
>> struct objalloc_chunk *l;
>>
>> - l = (struct objalloc_chunk *) o->chunks;
>> + l = o != NULL ? (struct objalloc_chunk *) o->chunks : NULL;
>
> I think the following would be cleaner and easier to understand:
> ```
> /* Handle a nullptr as being a no-op. */
> if (o == NULL)
> return;
> l = (struct objalloc_chunk *) o->chunks;
> ```
If already we're re-working this, can't the cast be dropped as well? Or is
libiberty still required to be buildable on pre-C89?
Jan
More information about the Binutils
mailing list