Menu

#23 `_duma_realloc` is not equivalent in behavior to `realloc`

open
nobody
None
5
2009-12-30
2009-12-30
No

`_duma_realloc` differs from the usual behavior of `realloc` in two ways: one in the case where the pointer parameter is `NULL`; the other in the case where the "new size" parameter is 0.

When the pointer parameter is `NULL`, the behavior of `realloc` per the C standard is to allocate memory as if a call to `malloc` were made. ISO/IEC 9899 says: "If `ptr` is a null pointer, the `realloc` function behaves like the `malloc` function for the specified size."

When the "new size" parameter is 0, the C standard says nothing about what `realloc` should do; however, C standard library implementations often deallocate the memory that is pointed to by the pointer parameter (as if a call to `free` were performed) and then return `NULL`. See http://www.cplusplus.com/reference/clibrary/cstdlib/realloc/

Discussion


Log in to post a comment.

Auth0 Logo