Fix REALLOC_ZERO_BYTES_FREES comment

Florian Weimer fweimer@redhat.com
Mon Apr 12 06:13:31 GMT 2021


* Paul Zimmermann:

>        Dear Paul,
>
>> From: Paul Eggert <eggert@cs.ucla.edu>
>> Date: Sun, 11 Apr 2021 14:42:22 -0700
>> 
>> While looking into problems with glibc's documentation of 
>> malloc/free/etc. I noticed that the comment for REALLOC_ZERO_BYTES_FREES 
>> was out of date: its reference to "the C standard" refers to ISO C11, 
>> but that compatibility problem has been fixed in C17. I installed the 
>> attached commentary fix as obvious.
>> 
>> [2:text/x-patch Show Save:0001-Fix-REALLOC_ZERO_BYTES_FREES-comment-to-match-C17.patch (1kB)]
>
> you write "If nonzero, ... should free p .... Otherwise ... should do the
> equivalent of freeing p". Is there a difference between "free p" and "do the
> equivalent of freeing p"?

It's freeing p followed by malloc (0).

> Also "ISO C17 says the behavior is implementation-defined here": I guess you
> mean the "default value of REALLOC_ZERO_BYTES_FREES", since for me the
> behavior is what is described above.

This part I find confusing as well, and also the “If nonzero”
clause—it's probably best to mention the REALLOC_ZERO_BYTES_FREES macro.
And maybe also clarify that the range of permitted C17 behaviors goes
beyond the two choices controlled by REALLOC_ZERO_BYTES_FREES.

Thanks,
Florian



More information about the Libc-alpha mailing list