mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-15 04:05:11 +01:00
gmem: Clarify that a NULL check is not needed before calling g_free()
It was documented before, but wasn’t especially clear. Doing if (X) g_free (X); is apparently quite a pervasive real-world anti-pattern, so perhaps it could be documented more explicitly. https://bugzilla.gnome.org/show_bug.cgi?id=741779
This commit is contained in:
parent
984576c01e
commit
18c9a4e17a
@ -181,7 +181,9 @@ g_realloc (gpointer mem,
|
|||||||
* @mem: (allow-none): the memory to free
|
* @mem: (allow-none): the memory to free
|
||||||
*
|
*
|
||||||
* Frees the memory pointed to by @mem.
|
* Frees the memory pointed to by @mem.
|
||||||
* If @mem is %NULL it simply returns.
|
*
|
||||||
|
* If @mem is %NULL it simply returns, so there is no need to check @mem
|
||||||
|
* against %NULL before calling this function.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
g_free (gpointer mem)
|
g_free (gpointer mem)
|
||||||
@ -281,7 +283,9 @@ g_try_malloc0 (gsize n_bytes)
|
|||||||
*
|
*
|
||||||
* Attempts to realloc @mem to a new size, @n_bytes, and returns %NULL
|
* Attempts to realloc @mem to a new size, @n_bytes, and returns %NULL
|
||||||
* on failure. Contrast with g_realloc(), which aborts the program
|
* on failure. Contrast with g_realloc(), which aborts the program
|
||||||
* on failure. If @mem is %NULL, behaves the same as g_try_malloc().
|
* on failure.
|
||||||
|
*
|
||||||
|
* If @mem is %NULL, behaves the same as g_try_malloc().
|
||||||
*
|
*
|
||||||
* Returns: the allocated memory, or %NULL.
|
* Returns: the allocated memory, or %NULL.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user