* HACKING: Summarized the functions applicable to the NULL tip.

This commit is contained in:
Roland Illig 2004-09-24 15:53:58 +00:00
parent 844d55b627
commit d13910537a

11
HACKING
View File

@ -311,8 +311,6 @@ Programming Tips
(This list should be sorted alphabetically.)
catstrs: (see NULL).
const: For every function taking a string argument, decide whether you
(as a user of the function) would expect that the string is modi-
fied by the function. If not, declare the string argument as
@ -327,16 +325,12 @@ const_cast: We use many libraries that do not know about "const char *" and
function does with the string, we should use g_strdup to pass
dynamically allocated strings.
execl, execle, execlp: (see NULL).
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);
g_strconcat: (see NULL).
g_strdup: When you use g_strdup to create a local copy of a string, use
the following pattern to keep the reference.
@ -357,6 +351,11 @@ NULL: When you pass NULL as an argument of a varargs function, cast the
a pointer are different, the argument will be passed as int 0,
not as a pointer.
This tip applies at least to catstrs (edit/edit.h), execl(3),
execle(3), execlp(3), g_strconcat (glib), parent_call
(src/background.h), parent_call_string (src/background.h),
rpc_get (vfs/mcfsutil.h), rpc_send (vfs/mcfsutil.h).
example:
char *path = g_strconcat("dir", "/", "file", (char *) NULL);