Re: should free() refer to posix_memalign?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jonny,

On 10/8/21 1:19 PM, Jonny Grant wrote:
Hello

https://man7.org/linux/man-pages/man3/malloc.3.html

"The free() function frees the memory space pointed to by ptr,
  which must have been returned by a previous call to malloc(),
  calloc(), or realloc().  "


Agree that this is somewhat wrong.


Could this list refer to the other ways memory can be allocated too? free() accepts other memory.
posix_memalign
aligned_alloc
memalign
valloc
pvalloc
reallocarray

That would be changing it to say :-

"The free() function frees the memory space pointed to by ptr,
  which must have been returned by a previous call to malloc(),
  calloc(), realloc(), posix_memalign(), aligned_alloc(), memalign(), valloc(), reallocarray() or pvalloc()"

I don't like that list. It is incomplete (the first one that comes to my mind is asprintf(3)). Either we provide a _complete_ list of functions that can be free(3)d, which I think will be difficult to keep up to date, or we use the same wording as POSIX, and say that it deallocates memory allocated as if by malloc(3).


What are your thoughts?

Thanks,

Alex

--
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux