summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-09-15 15:33:58 +0200
committerHaru <haru@dotalux.com>2015-10-11 00:24:21 +0200
commit4d806399aa529431f6c2a347930d91177d8a2bfa (patch)
tree45aa0a98e5f412ff6f7cbc399679c70d7221ce50 /src
parent9e2c59b0191e93effb7af82bb3e8e7e41bd75e67 (diff)
downloadhercules-4d806399aa529431f6c2a347930d91177d8a2bfa.tar.gz
hercules-4d806399aa529431f6c2a347930d91177d8a2bfa.tar.bz2
hercules-4d806399aa529431f6c2a347930d91177d8a2bfa.tar.xz
hercules-4d806399aa529431f6c2a347930d91177d8a2bfa.zip
Changed HPM->cmdline_plugins to a VECTOR and renamed to HPM->cmdline_load_plugins
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src')
-rw-r--r--src/common/HPM.c21
-rw-r--r--src/common/HPM.h3
2 files changed, 9 insertions, 15 deletions
diff --git a/src/common/HPM.c b/src/common/HPM.c
index 3fc0ab478..454da9fbb 100644
--- a/src/common/HPM.c
+++ b/src/common/HPM.c
@@ -558,8 +558,8 @@ void hplugin_unload(struct hplugin* plugin)
*/
CMDLINEARG(loadplugin)
{
- RECREATE(HPM->cmdline_plugins, char *, ++HPM->cmdline_plugins_count);
- HPM->cmdline_plugins[HPM->cmdline_plugins_count-1] = aStrdup(params);
+ VECTOR_ENSURE(HPM->cmdline_load_plugins, 1, 1);
+ VECTOR_PUSH(HPM->cmdline_load_plugins, aStrdup(params));
return true;
}
@@ -583,9 +583,9 @@ void hplugins_config_read(void) {
return;
plist = libconfig->lookup(&plugins_conf, "plugins_list");
- for (i = 0; i < HPM->cmdline_plugins_count; i++) {
+ for (i = 0; i < VECTOR_LENGTH(HPM->cmdline_load_plugins); i++) {
config_setting_t *entry = libconfig->setting_add(plist, NULL, CONFIG_TYPE_STRING);
- config_setting_set_string(entry, HPM->cmdline_plugins[i]);
+ config_setting_set_string(entry, VECTOR_INDEX(HPM->cmdline_load_plugins, i));
}
if (plist != NULL) {
@@ -912,14 +912,10 @@ void hpm_final(void)
VECTOR_CLEAR(HPM->config_listeners[i]);
}
- if (HPM->cmdline_plugins) {
- int j;
- for (j = 0; j < HPM->cmdline_plugins_count; j++)
- aFree(HPM->cmdline_plugins[j]);
- aFree(HPM->cmdline_plugins);
- HPM->cmdline_plugins = NULL;
- HPM->cmdline_plugins_count = 0;
+ while (VECTOR_LENGTH(HPM->cmdline_load_plugins)) {
+ aFree(VECTOR_POP(HPM->cmdline_load_plugins));
}
+ VECTOR_CLEAR(HPM->cmdline_load_plugins);
/* HPM->fnames is cleared after the memory manager goes down */
iMalloc->post_shutdown = hpm_memdown;
@@ -931,10 +927,9 @@ void hpm_defaults(void)
HPM = &HPM_s;
memset(&HPM->filenames, 0, sizeof(HPM->filenames));
+ VECTOR_INIT(HPM->cmdline_load_plugins);
HPM->force_return = false;
HPM->hooking = false;
- HPM->cmdline_plugins = NULL;
- HPM->cmdline_plugins_count = 0;
/* */
HPM->init = hpm_init;
HPM->final = hpm_final;
diff --git a/src/common/HPM.h b/src/common/HPM.h
index c3284527a..444829419 100644
--- a/src/common/HPM.h
+++ b/src/common/HPM.h
@@ -119,8 +119,7 @@ struct HPM_interface {
/* config listen */
VECTOR_DECL(struct HPConfListenStorage) config_listeners[HPCT_MAX];
/** Plugins requested through the command line */
- char **cmdline_plugins;
- int cmdline_plugins_count;
+ VECTOR_DECL(char *) cmdline_load_plugins;
/* funcs */
void (*init) (void);
void (*final) (void);