* HACKING (Programming tips): added a tip concerning the NULL
pointer in varargs function calls.
Этот коммит содержится в:
родитель
4bc786735e
Коммит
844d55b627
6
HACKING
6
HACKING
@ -311,6 +311,8 @@ Programming Tips
|
|||||||
|
|
||||||
(This list should be sorted alphabetically.)
|
(This list should be sorted alphabetically.)
|
||||||
|
|
||||||
|
catstrs: (see NULL).
|
||||||
|
|
||||||
const: For every function taking a string argument, decide whether you
|
const: For every function taking a string argument, decide whether you
|
||||||
(as a user of the function) would expect that the string is modi-
|
(as a user of the function) would expect that the string is modi-
|
||||||
fied by the function. If not, declare the string argument as
|
fied by the function. If not, declare the string argument as
|
||||||
@ -325,12 +327,16 @@ 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
|
function does with the string, we should use g_strdup to pass
|
||||||
dynamically allocated strings.
|
dynamically allocated strings.
|
||||||
|
|
||||||
|
execl, execle, execlp: (see NULL).
|
||||||
|
|
||||||
g_free: g_free handles NULL argument too, no need for the comparison.
|
g_free: g_free handles NULL argument too, no need for the comparison.
|
||||||
Bad way:
|
Bad way:
|
||||||
if (old_dir) g_free (old_dir);
|
if (old_dir) g_free (old_dir);
|
||||||
Right way:
|
Right way:
|
||||||
g_free (old_dir);
|
g_free (old_dir);
|
||||||
|
|
||||||
|
g_strconcat: (see NULL).
|
||||||
|
|
||||||
g_strdup: When you use g_strdup to create a local copy of a string, use
|
g_strdup: When you use g_strdup to create a local copy of a string, use
|
||||||
the following pattern to keep the reference.
|
the following pattern to keep the reference.
|
||||||
|
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user