From d7f753cd3aad6e997b9da85f6973890501496ea1 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Thu, 13 Dec 2007 00:14:02 +0100 Subject: [PATCH] Do not copy string passed to add_top_conf()/add_conf_item(). If the caller can keep a function pointer valid, they can certainly keep a string valid. This also fixes an error with HAVE_STRDUP undefined. --- include/newconf.h | 2 +- src/newconf.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/newconf.h b/include/newconf.h index 720f154..d35e539 100644 --- a/include/newconf.h +++ b/include/newconf.h @@ -24,7 +24,7 @@ struct ConfEntry struct TopConf { - char *tc_name; + const char *tc_name; int (*tc_sfunc) (struct TopConf *); int (*tc_efunc) (struct TopConf *); dlink_list tc_items; diff --git a/src/newconf.c b/src/newconf.c index cc55dff..9bb3c1f 100644 --- a/src/newconf.c +++ b/src/newconf.c @@ -85,7 +85,7 @@ add_top_conf(const char *name, int (*sfunc) (struct TopConf *), tc = MyMalloc(sizeof(struct TopConf)); - DupString(tc->tc_name, name); + tc->tc_name = name; tc->tc_sfunc = sfunc; tc->tc_efunc = efunc; tc->tc_entries = items; @@ -153,7 +153,6 @@ remove_top_conf(char *name) return -1; dlinkDestroy(ptr, &conf_items); - MyFree(tc->tc_name); MyFree(tc); return 0; @@ -1849,7 +1848,7 @@ add_conf_item(const char *topconf, const char *name, int type, void (*func) (voi cf = MyMalloc(sizeof(struct ConfEntry)); - DupString(cf->cf_name, name); + cf->cf_name = name; cf->cf_type = type; cf->cf_func = func; cf->cf_arg = NULL;