mirror of
https://github.com/RubyMetric/chsrc
synced 2025-08-14 08:29:32 +08:00
Warn when xy_strdup()
called with NULL
This commit is contained in:
parent
ca6498b547
commit
4ff53269f0
6
lib/xy.h
6
lib/xy.h
@ -287,6 +287,12 @@ xy_strjoin (unsigned int count, ...)
|
|||||||
static char *
|
static char *
|
||||||
xy_strdup (const char *str)
|
xy_strdup (const char *str)
|
||||||
{
|
{
|
||||||
|
if (!str)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "xy.h: xy_strdup() called with NULL!");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
size_t len = strlen (str);
|
size_t len = strlen (str);
|
||||||
char *new = xy_malloc0 (len + 1);
|
char *new = xy_malloc0 (len + 1);
|
||||||
strcpy (new, str);
|
strcpy (new, str);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user