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.
This commit is contained in:
Jilles Tjoelker 2007-12-13 00:14:02 +01:00
parent 19fcdbd561
commit d7f753cd3a
2 changed files with 3 additions and 4 deletions

View File

@ -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;

View File

@ -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;