[OPEN-ILS-DEV] C nits: strdup()
Scott McKellar
mck9 at swbell.net
Sun Apr 1 19:49:54 EDT 2007
The safe_malloc function and the OSRF_MALLOC macro carefully check
the return value from malloc(), and call exit() if malloc() ever fails.
Curiously, however, the code is not so meticulous about strdup(),
which also allocates memory, and which also can fail. Both in util.c
and elsewhere, the code routinely calls strdup() without checking for
NULL.
In the name of consistency, I propose a safe_strdup() and/or an
OSRF_STRDUP macro, along the same lines as safe_malloc() and
OSRF_MALLOC
(but without the memset(), of course).
Scott McKellar
http://home.swbell.net/mck9/aargh/
More information about the Open-ils-dev
mailing list