summaryrefslogtreecommitdiff
path: root/src/lib/utils.c
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2016-04-02 14:06:30 +0200
committerSander Vrijders <[email protected]>2016-04-02 14:06:30 +0200
commit8e1e865a25ec4e88f64b149764c239e286e42c49 (patch)
tree5c48ba6355e8465cccacdaf6b79c3922e0cbd332 /src/lib/utils.c
parent02972a88ac293356bcb4b03c8c6cd79735f7288a (diff)
downloadouroboros-8e1e865a25ec4e88f64b149764c239e286e42c49.tar.gz
ouroboros-8e1e865a25ec4e88f64b149764c239e286e42c49.zip
lib: Move strdup to utils
This moves strdup to utils to make it globally available.
Diffstat (limited to 'src/lib/utils.c')
-rw-r--r--src/lib/utils.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/lib/utils.c b/src/lib/utils.c
index ca082642..77a2d44c 100644
--- a/src/lib/utils.c
+++ b/src/lib/utils.c
@@ -20,6 +20,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <stdlib.h>
+#include <string.h>
+
int n_digits(unsigned i)
{
int n = 1;
@@ -31,3 +34,22 @@ int n_digits(unsigned i)
return n;
}
+
+char * strdup(const char * src)
+{
+ int len = 0;
+ char * dst = NULL;
+
+ if (src == NULL)
+ return NULL;
+
+ len = strlen(src) + 1;
+
+ dst = malloc(len);
+ if (dst == NULL)
+ return NULL;
+
+ memcpy(dst, src, len);
+
+ return dst;
+}