Bug 211039 - realloc with size 0
Summary: realloc with size 0
Status: RESOLVED DOCUMENTED
Alias: None
Product: Documentation
Classification: Unclassified
Component: man-pages (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: documentation_man-pages@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-04 19:21 UTC by johannes.pfister
Modified: 2021-01-11 14:39 UTC (History)
1 user (show)

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments
Specify the non-portability of realloc() with size 0 (649 bytes, patch)
2021-01-05 15:26 UTC, johannes.pfister
Details | Diff

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

Note You need to log in before you can comment on or make changes to this bug.