diff options
author | Sander Vrijders <[email protected]> | 2016-04-02 14:06:30 +0200 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2016-04-02 14:06:30 +0200 |
commit | 8e1e865a25ec4e88f64b149764c239e286e42c49 (patch) | |
tree | 5c48ba6355e8465cccacdaf6b79c3922e0cbd332 | |
parent | 02972a88ac293356bcb4b03c8c6cd79735f7288a (diff) | |
download | ouroboros-8e1e865a25ec4e88f64b149764c239e286e42c49.tar.gz ouroboros-8e1e865a25ec4e88f64b149764c239e286e42c49.zip |
lib: Move strdup to utils
This moves strdup to utils to make it globally available.
-rw-r--r-- | include/ouroboros/common.h | 2 | ||||
-rw-r--r-- | include/ouroboros/utils.h | 3 | ||||
-rw-r--r-- | src/lib/instance_name.c | 19 | ||||
-rw-r--r-- | src/lib/utils.c | 22 |
4 files changed, 26 insertions, 20 deletions
diff --git a/include/ouroboros/common.h b/include/ouroboros/common.h index 7114ed73..658c3618 100644 --- a/include/ouroboros/common.h +++ b/include/ouroboros/common.h @@ -45,7 +45,7 @@ struct qos_spec { /* FIXME: What should be configurable in the DIF? */ struct dif_config { /* general data */ - struct qos_spec * qosspecs; + char * dif_name; /* TODO: efficient policies */ diff --git a/include/ouroboros/utils.h b/include/ouroboros/utils.h index 0e50c039..2eaccae9 100644 --- a/include/ouroboros/utils.h +++ b/include/ouroboros/utils.h @@ -25,3 +25,6 @@ * need when represented as a string */ int n_digits(unsigned i); + +/* Returns a copy of the source string */ +char * strdup(const char * src); diff --git a/src/lib/instance_name.c b/src/lib/instance_name.c index 0f666211..2c70b419 100644 --- a/src/lib/instance_name.c +++ b/src/lib/instance_name.c @@ -33,25 +33,6 @@ #define instance_name_is_equal(a, b) (instance_name_cmp(a, b) == 0) -static 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; -} - instance_name_t * instance_name_create() { instance_name_t * tmp; 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; +} |