Bug 211039

Summary: realloc with size 0
Product: Documentation Reporter: johannes.pfister
Component: man-pagesAssignee: documentation_man-pages (documentation_man-pages)
Status: RESOLVED DOCUMENTED    
Severity: normal CC: alx
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: Subsystem:
Regression: No Bisected commit-id:
Attachments: Specify the non-portability of realloc() with size 0

Description johannes.pfister 2021-01-04 19:21:36 UTC
In the man page for realloc(3p)[1] does correctly mention the differences in the different C standards of the realloc(<somePointer>,0) behaviour. The malloc(3)[2] manpage, which also describes the realloc() function, does not mention it and says memory is freed with realloc(<somePointer>,0). This is the case in glibc but never C standards, C99 or newer, do not specify that memory is freed when size is 0 and there are systems which do not free memory with realloc(<somePointer>,0).

I argue both manpages should mention the different standards and that realloc(<somePointer>,0) is non-portable.


[1] https://man7.org/linux/man-pages/man3/realloc.3p.html
[2] https://man7.org/linux/man-pages/man3/malloc.3.html
Comment 1 johannes.pfister 2021-01-05 15:26:49 UTC
Created attachment 294513 [details]
Specify the non-portability of realloc() with size 0
Comment 2 Alejandro Colomar 2021-01-11 14:39:58 UTC
Fixed in commit da116d481b79892026029b442fb381713a09f123