summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/util.c b/util.c
new file mode 100644
index 0000000..70d815c
--- /dev/null
+++ b/util.c
@@ -0,0 +1,25 @@
+/* Copyright 2012-2013 NORDUnet A/S. All rights reserved.
+ See LICENSE for licensing information. */
+
+#include <stdlib.h>
+#include <string.h>
+#include <radsec/radsec.h>
+#include <radsec/radsec-impl.h>
+#include "util.h"
+
+char *
+rs_strdup (struct rs_context *ctx, const char *s)
+{
+ size_t len;
+ char *buf;
+
+ len = strlen (s);
+ buf = rs_malloc (ctx, len + 1);
+
+ if (buf != NULL)
+ memcpy (buf, s, len + 1);
+ else
+ rs_err_ctx_push (ctx, RSE_NOMEM, __func__);
+
+ return buf;
+}