]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
module: remove leaking mm_realloc and useless mm_ctx
authorDaniel Salzman <daniel.salzman@nic.cz>
Tue, 5 Jun 2018 10:31:47 +0000 (12:31 +0200)
committerDaniel Salzman <daniel.salzman@nic.cz>
Tue, 5 Jun 2018 14:23:24 +0000 (16:23 +0200)
src/knot/conf/module.c
src/knot/nameserver/query_module.c
src/knot/nameserver/query_module.h

index 0d61b12a3380df155dc7d24e0b38734c62151e08..73c31fc0a584bc112f088c1125a472d272e5841f 100644 (file)
@@ -397,7 +397,7 @@ void conf_activate_modules(
 
                // Open the module.
                knotd_mod_t *mod = query_module_open(conf, mod_id, *query_plan,
-                                                    zone_name, conf->mm);
+                                                    zone_name);
                if (mod == NULL) {
                        MOD_ID_LOG(zone_name, error, mod_id, "failed to open");
                        conf_free_mod_id(mod_id);
index 1273b022c3cf0345bc92f935cd418650c4be1b32..73aa384ebc1ba6d8341213089b6d884e32038213 100644 (file)
@@ -1,4 +1,4 @@
-/*  Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/*  Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -124,8 +124,7 @@ int knotd_mod_in_hook(knotd_mod_t *mod, knotd_stage_t stage, knotd_mod_in_hook_f
 }
 
 knotd_mod_t *query_module_open(conf_t *conf, conf_mod_id_t *mod_id,
-                               struct query_plan *plan, const knot_dname_t *zone,
-                               knot_mm_t *mm)
+                               struct query_plan *plan, const knot_dname_t *zone)
 {
        if (conf == NULL || mod_id == NULL || plan == NULL) {
                return NULL;
@@ -139,13 +138,12 @@ knotd_mod_t *query_module_open(conf_t *conf, conf_mod_id_t *mod_id,
        }
 
        /* Create query module. */
-       knotd_mod_t *module = mm_calloc(mm, 1, sizeof(knotd_mod_t));
+       knotd_mod_t *module = calloc(1, sizeof(knotd_mod_t));
        if (module == NULL) {
                return NULL;
        }
 
        module->plan = plan;
-       module->mm = mm;
        module->config = conf;
        module->zone = zone;
        module->id = mod_id;
@@ -162,7 +160,7 @@ void query_module_close(knotd_mod_t *module)
 
        knotd_mod_stats_free(module);
        conf_free_mod_id(module->id);
-       mm_free(module->mm, module);
+       free(module);
 }
 
 _public_
@@ -230,7 +228,7 @@ int knotd_mod_stats_add(knotd_mod_t *mod, const char *ctr_name, uint32_t idx_cou
        mod_ctr_t *stats = NULL;
        if (mod->stats == NULL) {
                assert(mod->stats_count == 0);
-               stats = mm_alloc(mod->mm, sizeof(*stats));
+               stats = malloc(sizeof(*stats));
                if (stats == NULL) {
                        return KNOT_ENOMEM;
                }
@@ -239,7 +237,7 @@ int knotd_mod_stats_add(knotd_mod_t *mod, const char *ctr_name, uint32_t idx_cou
                assert(mod->stats_count > 0);
                size_t old_size = mod->stats_count * sizeof(*stats);
                size_t new_size = old_size + sizeof(*stats);
-               stats = mm_realloc(mod->mm, mod->stats, new_size, old_size);
+               stats = realloc(mod->stats, new_size);
                if (stats == NULL) {
                        knotd_mod_stats_free(mod);
                        return KNOT_ENOMEM;
@@ -254,7 +252,7 @@ int knotd_mod_stats_add(knotd_mod_t *mod, const char *ctr_name, uint32_t idx_cou
                stats->counter = 0;
        } else {
                size_t size = idx_count * sizeof(((mod_ctr_t *)0)->counter);
-               stats->counters = mm_calloc(mod->mm, 1, size);
+               stats->counters = calloc(1, size);
                if (stats->counters == NULL) {
                        knotd_mod_stats_free(mod);
                        return KNOT_ENOMEM;
@@ -276,11 +274,11 @@ void knotd_mod_stats_free(knotd_mod_t *mod)
 
        for (int i = 0; i < mod->stats_count; i++) {
                if (mod->stats[i].count > 1) {
-                       mm_free(mod->mm, mod->stats[i].counters);
+                       free(mod->stats[i].counters);
                }
        }
 
-       mm_free(mod->mm, mod->stats);
+       free(mod->stats);
 }
 
 #define STATS_BODY(OPERATION) { \
index 31d0289822eca16b31e7a7497be435d48fb4b343..0c4fdc19d307d245234d8b3f145f3deafb5c0c0e 100644 (file)
@@ -1,4 +1,4 @@
-/*  Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/*  Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -60,8 +60,7 @@ int query_plan_step(struct query_plan *plan, knotd_stage_t stage,
 
 /*! \brief Open query module identified by name. */
 knotd_mod_t *query_module_open(conf_t *conf, conf_mod_id_t *mod_id,
-                               struct query_plan *plan, const knot_dname_t *zone,
-                               knot_mm_t *mm);
+                               struct query_plan *plan, const knot_dname_t *zone);
 
 /*! \brief Close query module. */
 void query_module_close(knotd_mod_t *module);
@@ -82,7 +81,6 @@ typedef struct {
 
 struct knotd_mod {
        node_t node;
-       knot_mm_t *mm;
        conf_t *config;
        conf_mod_id_t *id;
        struct query_plan *plan;