summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 019b96a)
raw | patch | inline | side by side (parent: 019b96a)
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Mon, 21 Oct 2002 04:05:48 +0000 (04:05 +0000) | ||
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Mon, 21 Oct 2002 04:05:48 +0000 (04:05 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@150 f882894a-f735-0410-b71e-b25c423dba1c
plugins/utils.c | patch | blob | history |
diff --git a/plugins/utils.c b/plugins/utils.c
index 697b5a66867f397ad758df3e7adba435231638ac..a4519f250c9d0f06385a7c88fbc0f5d9736515e4 100644 (file)
--- a/plugins/utils.c
+++ b/plugins/utils.c
/******************************************************************************
*
- * Copies one string to another
- *
- * Given a pointer destination string, which may or may not already
- * hold some text, and a source string with additional text (possibly
- * NULL or empty), returns a pointer to a a copy of the source
- * string. Uses realloc to free memory held by the dest argument if
- * new storage space is required, and any previously existing data in
+ * Copies one string to another. Any previously existing data in
* the destination string is lost.
*
* Example:
size_t len;
if (src == NULL)
- return dest;
-
- len = strlen (src) + 1;
- if (dest == NULL)
- dest = malloc (len);
- else if (strlen (dest) < len)
- dest = realloc (dest, len);
- if (dest == NULL)
- terminate (STATE_UNKNOWN, "failed realloc in strscpy\n");
+ return NULL;
- strncpy (dest, src, len);
+ asprintf (&dest, "%s", src);
return dest;
}