conf parsing: Fix memory leaks and clean up code a bit.

Charybdis currently leaks about 45-50k per configuration parse,
including every rehash. This change plugs these leaks by properly
iterating through all conf_parm_t structures to seek all strings that
should be freed and also by freeing the conf_parm_t structures
themselves.

These leaks have been present since the original rewrite of the
configuration parsing system in ircd-ratbox r11953.

Additionally, this change also cleans up and documents the parsing code
a bit.
This commit is contained in:
Keith Buck 2014-02-28 07:02:49 +00:00
parent e8cfec47c6
commit dceac3e4fb
3 changed files with 37 additions and 30 deletions

View file

@ -25,19 +25,27 @@ struct TopConf
};
#define CF_QSTRING 0x01
#define CF_QSTRING 0x01 /* quoted string */
#define CF_INT 0x02
#define CF_STRING 0x03
#define CF_STRING 0x03 /* unquoted string */
#define CF_TIME 0x04
#define CF_YESNO 0x05
#define CF_LIST 0x06
#define CF_ONE 0x07
#define CF_MTYPE 0xFF
#define CF_MTYPE 0xFF /* mask for type */
#define CF_FLIST 0x1000
#define CF_MFLAG 0xFF00
/* CF_FLIST is used to allow specifying that an option accepts a list of (type)
* values. conf_parm_t.type will never actually have another type & CF_FLIST;
* it's only used as a true flag in newconf.c (which only consumes conf_parm_t
* structures and doesn't create them itself).
*/
#define CF_FLIST 0x0100 /* flag for list */
#define CF_MFLAG 0xFF00 /* mask for flags */
/* conf_parm_t.type must be either one type OR one flag. this is pretty easy to
* enforce because lists always contain nested conf_parm_t structures whose
* .type is the real type, so it doesn't need to be stored in the top-level one
* anyway.
*/
typedef struct conf_parm_t_stru
{
struct conf_parm_t_stru *next;
@ -59,7 +67,7 @@ extern char *current_file;
int read_config(char *);
int conf_start_block(char *, char *);
int conf_end_block(struct TopConf *);
int conf_call_set(struct TopConf *, char *, conf_parm_t *, int);
int conf_call_set(struct TopConf *, char *, conf_parm_t *);
void conf_report_error(const char *, ...);
void newconf_init(void);
int add_conf_item(const char *topconf, const char *name, int type, void (*func) (void *));