summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYannick Gicquel <yannick.gicquel@iot.bzh>2016-01-28 16:29:31 +0100
committerYannick Gicquel <yannick.gicquel@iot.bzh>2016-01-28 16:29:31 +0100
commita4b35de73384d4394b5201838c1c785355d9a7fd (patch)
tree443f1e5fd702c45fde7dd372f3e8005a7f7525fc
parentc4ec16f3868b099f2904b54be78bcd09d3760a24 (diff)
rest-api: fixup AFB_plugins allocated references
plugins handles pointer to AFB_plugin structures which are located in each dynamically loaded plugin. Signed-off-by: Yannick Gicquel <yannick.gicquel@iot.bzh>
-rw-r--r--src/rest-api.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/rest-api.c b/src/rest-api.c
index b0d7af00..e1c3756c 100644
--- a/src/rest-api.c
+++ b/src/rest-api.c
@@ -636,8 +636,7 @@ STATIC void scanDirectory(char *dirpath, int dirfd, AFB_plugin **plugins, int *c
}
if (verbose) fprintf(stderr, "[%s] is a valid AFB plugin, loading pos[%d]\n", pluginDir.d_name, *count);
- plugins[*count] = (AFB_plugin *) malloc (sizeof(AFB_plugin));
- plugins[*count] = (**pluginRegisterFct)();
+ plugins[*count] = pluginRegisterFct();
*count = *count +1;
}
@@ -646,7 +645,7 @@ STATIC void scanDirectory(char *dirpath, int dirfd, AFB_plugin **plugins, int *c
}
void initPlugins(AFB_session *session) {
- static AFB_plugin **plugins;
+ AFB_plugin **plugins;
afbJsonType = json_object_new_string (AFB_MSG_JTYPE);
int count = 0;
@@ -654,7 +653,7 @@ void initPlugins(AFB_session *session) {
int dirfd;
/* pre-allocate for AFB_MAX_PLUGINS plugins, we will downsize later */
- plugins = (AFB_plugin **) malloc (AFB_MAX_PLUGINS *sizeof(AFB_plugin));
+ plugins = (AFB_plugin **) malloc (AFB_MAX_PLUGINS *sizeof(AFB_plugin*));
// Loop on every directory passed in --plugins=xxx
while (dirpath = strsep(&session->config->ldpaths, ":")) {
@@ -673,7 +672,7 @@ void initPlugins(AFB_session *session) {
}
// downsize structure to effective number of loaded plugins
- plugins = (AFB_plugin **)realloc (plugins, (count+1)*sizeof(AFB_plugin));
+ plugins = (AFB_plugin **)realloc (plugins, (count+1)*sizeof(AFB_plugin*));
plugins[count] = NULL;
// complete plugins and save them within current sessions