From: Martin Mares Date: Mon, 10 May 2004 14:10:39 +0000 (+0000) Subject: cfg_stralloc() -> cfg_strdup() and use mp_strdup() to implement it. X-Git-Tag: holmes-import~1068 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=4173fe3acfb504f789739b870436d211cf3df34e;p=libucw.git cfg_stralloc() -> cfg_strdup() and use mp_strdup() to implement it. --- 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