From 4173fe3acfb504f789739b870436d211cf3df34e Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 10 May 2004 14:10:39 +0000 Subject: [PATCH] cfg_stralloc() -> cfg_strdup() and use mp_strdup() to implement it. --- lib/conf.c | 11 ++++------- lib/conf.h | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/conf.c b/lib/conf.c index 35f0502b..effdbd9c 100644 --- a/lib/conf.c +++ b/lib/conf.c @@ -43,12 +43,9 @@ cfg_malloc(uns size) } byte * -cfg_stralloc(byte *s) +cfg_strdup(byte *s) { - uns l = strlen(s); - byte *k = cfg_malloc(l + 1); - strcpy(k, s); - return k; + return mp_strdup(cfpool, s); } void cf_register(struct cfitem *items) @@ -217,10 +214,10 @@ byte *cf_set_item(byte *sect, byte *name, byte *value) msg = cf_parse_int(value, (uns *) item->var); break; case CT_STRING: - *((byte **) item->var) = cfg_stralloc(value); + *((byte **) item->var) = cfg_strdup(value); break; case CT_FUNCTION: - msg = ((ci_func) item->var)(item, cfg_stralloc(value)); + msg = ((ci_func) item->var)(item, cfg_strdup(value)); break; case CT_DOUBLE: msg = cf_parse_double(value, (double *) item->var); diff --git a/lib/conf.h b/lib/conf.h index 55589c4e..18486823 100644 --- a/lib/conf.h +++ b/lib/conf.h @@ -19,7 +19,7 @@ extern struct mempool *cfpool; void *cfg_malloc(uns size); -byte *cfg_stralloc(byte *s); +byte *cfg_strdup(byte *s); /* * Every module places its configuration setting into some section. Section is -- 2.39.2