Our statup sequence is 'load_config', 'init_checkers', and 'init_prio'.
Both init_* functions reset the list of prio and checkers, which is
unfortunate as in load_config, depending on the multipat.conf, would
load prio and checker libraries. This results in double-loading of
the libraries and a memory leak.
int init_checkers (void)
{
- INIT_LIST_HEAD(&checkers);
if (!add_checker(DEFAULT_CHECKER))
return 1;
return 0;
struct checker * alloc_checker (void)
{
- return zalloc(sizeof(struct checker));
+ return MALLOC(sizeof(struct checker));
}
void free_checker (struct checker * c)
{
- free(c);
+ FREE(c);
}
void cleanup_checkers (void)
list_for_each_entry_safe(checker_loop, checker_temp, &checkers, node) {
list_del(&checker_loop->node);
- free(checker_loop);
+ free_checker(checker_loop);
}
}
char * checker_state_name (int);
int init_checkers (void);
+void cleanup_checkers (void);
struct checker * add_checker (char *);
struct checker * checker_lookup (char *);
int checker_init (struct checker *, void **);
int init_prio (void)
{
- INIT_LIST_HEAD(&prioritizers);
if (!add_prio(DEFAULT_PRIO))
return 1;
return 0;
struct prio * alloc_prio (void)
{
- return zalloc(sizeof(struct prio));
+ return MALLOC(sizeof(struct prio));
}
void free_prio (struct prio * p)
{
- free(p);
+ FREE(p);
}
void cleanup_prio(void)
list_for_each_entry_safe(prio_loop, prio_temp, &prioritizers, node) {
list_del(&prio_loop->node);
- free(prio_loop);
+ free_prio(prio_loop);
}
}
};
int init_prio (void);
+void cleanup_prio (void);
struct prio * add_prio (char *);
struct prio * prio_lookup (char *);
int prio_getprio (struct prio *, struct path *);
dm_lib_release();
dm_lib_exit();
+ cleanup_prio();
+ cleanup_checkers();
/*
* Freeing config must be done after dm_lib_exit(), because
* the logging function (dm_write_log()), which is called there,
dm_lib_release();
dm_lib_exit();
+ cleanup_prio();
+ cleanup_checkers();
/*
* Freeing config must be done after condlog() and dm_lib_exit(),
* because logging functions like dlog() and dm_write_log()