summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJose Bollo <jose.bollo@iot.bzh>2018-07-25 14:13:36 +0200
committerJose Bollo <jose.bollo@iot.bzh>2018-07-25 15:12:48 +0200
commit9c2e6e45d4c9745c4702ac1992a0cb086e99fb0b (patch)
treeacfd70be619b6b7fe25dc9e6c5e66c137f3fc597
parentf96bbb49cc9bcd81693300191cf7a01b879fd83d (diff)
Fix some more memory leaks
While making coverage test, few leaks appeared. This corrects the last discorvered ones. Change-Id: Id9e508bc9412072b628742971b02dd3d62799f3f Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-api-v3.c3
-rw-r--r--src/afb-config.c30
2 files changed, 6 insertions, 27 deletions
diff --git a/src/afb-api-v3.c b/src/afb-api-v3.c
index 1bda6b08..02853b12 100644
--- a/src/afb-api-v3.c
+++ b/src/afb-api-v3.c
@@ -239,6 +239,9 @@ void afb_api_v3_unref(struct afb_api_v3 *api)
{
if (api && !__atomic_sub_fetch(&api->refcount, 1, __ATOMIC_RELAXED)) {
afb_export_destroy(api->export);
+ while (api->count)
+ free(api->verbs[--api->count]);
+ free(api->verbs);
free(api);
}
}
diff --git a/src/afb-config.c b/src/afb-config.c
index 3c0d28e9..a791969f 100644
--- a/src/afb-config.c
+++ b/src/afb-config.c
@@ -396,30 +396,6 @@ static void printHelp(FILE * file, const char *name)
name);
}
-/*---------------------------------------------------------
- | helpers for argument scanning
- +--------------------------------------------------------- */
-
-static const char *current_argument(int optid)
-{
- if (optarg == 0) {
- ERROR("option [--%s] needs a value i.e. --%s=xxx",
- name_of_optid(optid), name_of_optid(optid));
- exit(1);
- }
- return optarg;
-}
-
-static char *argvalstr(int optid)
-{
- char *result = strdup(current_argument(optid));
- if (result == NULL) {
- ERROR("can't alloc memory");
- exit(1);
- }
- return result;
-}
-
/**********************************
* json helpers
***********************************/
@@ -584,9 +560,9 @@ static void config_add_optstr(struct json_object *config, int optid)
| set the log levels
+--------------------------------------------------------- */
-static void set_log(char *args)
+static void set_log(const char *args)
{
- char o = 0, s, *p, *i = args;
+ char o = 0, s, *p, *i = strdupa(args);
int lvl;
for(;;) switch (*i) {
@@ -653,7 +629,7 @@ static void parse_arguments_inner(int argc, char **argv, struct json_object *con
break;
case SET_LOG:
- set_log(argvalstr(optid));
+ set_log(get_arg(optid));
break;
case SET_PORT: