* HACKING: Add to section "Programming Tips" g_free tip.

This commit is contained in:
Andrew V. Samoilov 2004-09-03 21:39:32 +00:00
parent c9f834b501
commit e5f21875a3
2 changed files with 10 additions and 0 deletions

View File

@ -1,3 +1,7 @@
2004-09-04 Pavel S. Shirshov <pavelsh@mail.ru>
* HACKING: Add to section "Programming Tips" g_free tip.
2004-09-02 Roland Illig <roland.illig@gmx.de> 2004-09-02 Roland Illig <roland.illig@gmx.de>
* HACKING: Added a section "Programming Tips" which lists mistakes * HACKING: Added a section "Programming Tips" which lists mistakes

View File

@ -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 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). 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);