Use malloc+memcpy rather than calloc+strcpy in rs_strdup.
[libradsec.git] / lib / util.c
1 /* Copyright 2012,2013 NORDUnet A/S. All rights reserved.
2    See LICENSE for licensing information.  */
3
4 #include <string.h>
5 #include <radsec/radsec.h>
6 #include <radsec/radsec-impl.h>
7 #include "util.h"
8
9 char *
10 rs_strdup (struct rs_context *ctx, const char *s)
11 {
12   size_t len;
13   char *buf;
14
15   len = strlen (s);
16   buf = rs_malloc (ctx, len + 1);
17
18   if (buf != NULL)
19     memcpy (buf, s, len + 1);
20   else
21     rs_err_ctx_push (ctx, RSE_NOMEM, __func__);
22
23   return buf;
24 }