diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-07-12 20:57:04 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-07-12 20:57:04 +0300 |
commit | 17ffc295b10b17f04b4db3cef62bceb2a9768f43 (patch) | |
tree | 78fb69c08665d30f9f9b8bbdc2b992dda166753d /src/emap/hashtable.c | |
parent | 763069245561fb981e97120f60ca417fd481ebf9 (diff) | |
download | plugin-17ffc295b10b17f04b4db3cef62bceb2a9768f43.tar.gz plugin-17ffc295b10b17f04b4db3cef62bceb2a9768f43.tar.bz2 plugin-17ffc295b10b17f04b4db3cef62bceb2a9768f43.tar.xz plugin-17ffc295b10b17f04b4db3cef62bceb2a9768f43.zip |
Fix crash on exit if any hash iterators was used in scripts.s20170725
Also improve a bit hashtable cleanup code.
Diffstat (limited to 'src/emap/hashtable.c')
-rw-r--r-- | src/emap/hashtable.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/emap/hashtable.c b/src/emap/hashtable.c index 9d2908d..6645a0d 100644 --- a/src/emap/hashtable.c +++ b/src/emap/hashtable.c @@ -117,6 +117,7 @@ bool htreg_destroy_iterator(int64 id) if (it) { dbi_destroy(it); + i64db_remove(htreg->iterators, id); return true; } return false; @@ -160,23 +161,29 @@ void htreg_init(void) */ void htreg_final(void) { - struct DBIterator *iter = db_iterator(htreg->htables); - struct DBMap *ht; - for(ht=dbi_first(iter); dbi_exists(iter); ht=dbi_next(iter)) - db_destroy(ht); + if (htreg->htables != NULL) + { + struct DBMap *ht; + struct DBIterator *iter = db_iterator(htreg->htables); + for (ht = dbi_first(iter); dbi_exists(iter); ht = dbi_next(iter)) + db_destroy(ht); - dbi_destroy(iter); + dbi_destroy(iter); + } db_destroy(htreg->htables); // NOTE: maybe I should destroy iteratos before hashtables - struct DBIterator *it; - iter = db_iterator(htreg->iterators); - for (it=dbi_first(iter); dbi_exists(iter); it=dbi_next(iter)) - dbi_destroy(it); + if (htreg->iterators != NULL) + { + struct DBIterator *it; + struct DBIterator *iter = db_iterator(htreg->iterators); + for (it = dbi_first(iter); dbi_exists(iter); it = dbi_next(iter)) + dbi_destroy(it); - dbi_destroy(iter); + dbi_destroy(iter); + } db_destroy(htreg->iterators); } |