From e5f21875a3d64fa964f016c948ff63e93db5a2d7 Mon Sep 17 00:00:00 2001 From: "Andrew V. Samoilov" Date: Fri, 3 Sep 2004 21:39:32 +0000 Subject: [PATCH] * HACKING: Add to section "Programming Tips" g_free tip. --- ChangeLog | 4 ++++ HACKING | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index 26a8fad97..262763f85 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-09-04 Pavel S. Shirshov + + * HACKING: Add to section "Programming Tips" g_free tip. + 2004-09-02 Roland Illig * HACKING: Added a section "Programming Tips" which lists mistakes diff --git a/HACKING b/HACKING index 50085cbd1..a2d31da85 100644 --- a/HACKING +++ b/HACKING @@ -296,3 +296,9 @@ size_t: This data type is suitable for expressing sizes of memory or the strncpy: Don't use this function in newly created code. It is slow, insecure and hard to use. A much better alternative is g_strlcpy (see there). + +g_free: g_free handles NULL argument too, no need for the comparison. + Bad way: + if (old_dir) g_free (old_dir); + Right way: + g_free (old_dir);