From 8e1e865a25ec4e88f64b149764c239e286e42c49 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Sat, 2 Apr 2016 14:06:30 +0200 Subject: lib: Move strdup to utils This moves strdup to utils to make it globally available. --- src/lib/instance_name.c | 19 ------------------- src/lib/utils.c | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 19 deletions(-) (limited to 'src/lib') 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 +#include + 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; +} -- cgit v1.2.3 From 9fed4c5bdb4928c7f5c73e85888de54672cd4c56 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Sat, 2 Apr 2016 17:17:39 +0200 Subject: lib: Remove check for equal names Removes name_is_equal. Just using instance_name_cmp is encouraged. It also removes a wrong initialization in the irm tool. --- src/lib/instance_name.c | 2 -- src/tools/irm/irm_bootstrap_ipcp.c | 2 -- 2 files changed, 4 deletions(-) (limited to 'src/lib') diff --git a/src/lib/instance_name.c b/src/lib/instance_name.c index 2c70b419..e560c0b9 100644 --- a/src/lib/instance_name.c +++ b/src/lib/instance_name.c @@ -31,8 +31,6 @@ #include #include -#define instance_name_is_equal(a, b) (instance_name_cmp(a, b) == 0) - instance_name_t * instance_name_create() { instance_name_t * tmp; diff --git a/src/tools/irm/irm_bootstrap_ipcp.c b/src/tools/irm/irm_bootstrap_ipcp.c index c7b82c4a..03a913fb 100644 --- a/src/tools/irm/irm_bootstrap_ipcp.c +++ b/src/tools/irm/irm_bootstrap_ipcp.c @@ -42,8 +42,6 @@ int do_bootstrap_ipcp(int argc, char ** argv) instance_name_t api = {NULL, 0}; struct dif_config conf; - conf.qosspecs = NULL; - while (argc > 0) { if (matches(*argv, "ap") == 0) { api.name = *(argv + 1); -- cgit v1.2.3