summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 088d5c6)
raw | patch | inline | side by side (parent: 088d5c6)
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 119d284fdfd2d72d94e98220953151d33ea256ff..ae89c44f9aee71ceaf5ceb8df2e117ef418d2d1f 100644 (file)
--- a/src/common.c
+++ b/src/common.c
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 */