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:
parent
19fcdbd561
commit
d7f753cd3a
2 changed files with 3 additions and 4 deletions
|
@ -24,7 +24,7 @@ struct ConfEntry
|
||||||
|
|
||||||
struct TopConf
|
struct TopConf
|
||||||
{
|
{
|
||||||
char *tc_name;
|
const char *tc_name;
|
||||||
int (*tc_sfunc) (struct TopConf *);
|
int (*tc_sfunc) (struct TopConf *);
|
||||||
int (*tc_efunc) (struct TopConf *);
|
int (*tc_efunc) (struct TopConf *);
|
||||||
dlink_list tc_items;
|
dlink_list tc_items;
|
||||||
|
|
|
@ -85,7 +85,7 @@ add_top_conf(const char *name, int (*sfunc) (struct TopConf *),
|
||||||
|
|
||||||
tc = MyMalloc(sizeof(struct TopConf));
|
tc = MyMalloc(sizeof(struct TopConf));
|
||||||
|
|
||||||
DupString(tc->tc_name, name);
|
tc->tc_name = name;
|
||||||
tc->tc_sfunc = sfunc;
|
tc->tc_sfunc = sfunc;
|
||||||
tc->tc_efunc = efunc;
|
tc->tc_efunc = efunc;
|
||||||
tc->tc_entries = items;
|
tc->tc_entries = items;
|
||||||
|
@ -153,7 +153,6 @@ remove_top_conf(char *name)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
dlinkDestroy(ptr, &conf_items);
|
dlinkDestroy(ptr, &conf_items);
|
||||||
MyFree(tc->tc_name);
|
|
||||||
MyFree(tc);
|
MyFree(tc);
|
||||||
|
|
||||||
return 0;
|
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));
|
cf = MyMalloc(sizeof(struct ConfEntry));
|
||||||
|
|
||||||
DupString(cf->cf_name, name);
|
cf->cf_name = name;
|
||||||
cf->cf_type = type;
|
cf->cf_type = type;
|
||||||
cf->cf_func = func;
|
cf->cf_func = func;
|
||||||
cf->cf_arg = NULL;
|
cf->cf_arg = NULL;
|
||||||
|
|
Loading…
Reference in a new issue