projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
088d5c6
)
src/common.c: Change `sstrdup' to not call `strdup' anymore.
author
Florian Forster
<octo@leeloo.lan.home.verplant.org>
Sat, 20 Dec 2008 15:55:10 +0000
(16:55 +0100)
committer
Florian Forster
<octo@leeloo.lan.home.verplant.org>
Sat, 20 Dec 2008 15:55:10 +0000
(16:55 +0100)
src/common.c
patch
|
blob
|
history
diff --git
a/src/common.c
b/src/common.c
index
119d284
..
ae89c44
100644
(file)
--- a/
src/common.c
+++ b/
src/common.c
@@
-77,15
+77,21
@@
int ssnprintf (char *dest, size_t n, const char *format, ...)
char *sstrdup (const char *s)
{
char *r;
+ size_t sz;
if (s == NULL)
return (NULL);
- if((r = strdup (s)) == NULL)
+ /* Do not use `strdup' here, because it's not specified in POSIX. It's
+ * ``only'' an XSI extension. */
+ sz = strlen (s) + 1;
+ r = (char *) malloc (sizeof (char) * sz);
+ if (r == NULL)
{
- ERROR ("
Not enough
memory.");
+ ERROR ("
sstrdup: Out of
memory.");
exit (3);
}
+ memcpy (r, s, sizeof (char) * sz);
return (r);
} /* char *sstrdup */