[glib/no-free-check] Do not check for NULL when calling free()
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/no-free-check] Do not check for NULL when calling free()
- Date: Tue, 18 Dec 2018 13:30:40 +0000 (UTC)
commit 84d013ed463838dbd065ec538009bd9bd7a8806f
Author: Emmanuele Bassi <ebassi gnome org>
Date: Tue Dec 18 13:27:43 2018 +0000
Do not check for NULL when calling free()
The C standard guarantees that `free()` is `NULL`-safe.
glib/gmem.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
---
diff --git a/glib/gmem.c b/glib/gmem.c
index b72a58335..09cd04140 100644
--- a/glib/gmem.c
+++ b/glib/gmem.c
@@ -170,8 +170,7 @@ g_realloc (gpointer mem,
G_STRLOC, n_bytes);
}
- if (mem)
- free (mem);
+ free (mem);
TRACE (GLIB_MEM_REALLOC((void*) NULL, (void*)mem, 0, 0));
@@ -190,8 +189,7 @@ g_realloc (gpointer mem,
void
g_free (gpointer mem)
{
- if (G_LIKELY (mem))
- free (mem);
+ free (mem);
TRACE(GLIB_MEM_FREE((void*) mem));
}
@@ -304,8 +302,7 @@ g_try_realloc (gpointer mem,
else
{
newmem = NULL;
- if (mem)
- free (mem);
+ free (mem);
}
TRACE (GLIB_MEM_REALLOC((void*) newmem, (void*)mem, (unsigned int) n_bytes, 1));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]