[Pkg-voip-commits] [bctoolbox] 33/57: fix memorly leak in friends map
daniel at gnoutcheff.name
daniel at gnoutcheff.name
Thu Mar 30 04:31:33 UTC 2017
This is an automated email from the git hooks/post-receive script.
gnoutchd-guest pushed a commit to branch debian/sid
in repository bctoolbox.
commit 2046ff694ec498dfed7d93fa47921ac4baa8775b
Author: Benjamin Reis <benjamin.reis at belledonne-communications.com>
Date: Fri Jan 20 14:18:17 2017 +0100
fix memorly leak in friends map
---
include/bctoolbox/map.h | 2 ++
src/containers/map.cc | 18 ++++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/include/bctoolbox/map.h b/include/bctoolbox/map.h
index 0b08e84..dc72882 100644
--- a/include/bctoolbox/map.h
+++ b/include/bctoolbox/map.h
@@ -31,6 +31,8 @@ typedef struct _bctbx_iterator_t bctbx_iterator_t;
typedef struct _bctbx_mmap_ullong_t bctbx_mmap_ullong_t;
typedef struct _bctbx_mmap_cchar_t bctbx_mmap_cchar_t;
+
+typedef void (*bctbx_map_free_func)(void *);
/*map*/
BCTBX_PUBLIC bctbx_map_t *bctbx_mmap_ullong_new(void);
BCTBX_PUBLIC bctbx_map_t *bctbx_mmap_cchar_new(void);
diff --git a/src/containers/map.cc b/src/containers/map.cc
index c58ef87..36f1af8 100644
--- a/src/containers/map.cc
+++ b/src/containers/map.cc
@@ -47,6 +47,24 @@ extern "C" void bctbx_mmap_ullong_delete(bctbx_map_t *mmap) {
extern "C" void bctbx_mmap_cchar_delete(bctbx_map_t *mmap) {
bctbx_mmap_delete<mmap_cchar_t>(mmap);
}
+extern "C" void bctbx_mmap_ullong_delete_with_data(bctbx_map_t *mmap, bctbx_map_free_func freefunc) {
+ bctbx_iterator_t *it = bctbx_map_ullong_begin(mmap);
+ while(it) {
+ bctbx_pair_t *pair = bctbx_iterator_ullong_get_pair(it);
+ freefunc(bctbx_pair_ullong_get_second(pair));
+ it = bctbx_iterator_ullong_get_next(it);
+ }
+ bctbx_mmap_ullong_delete(mmap);
+}
+extern "C" void bctbx_mmap_cchar_delete_with_data(bctbx_map_t *mmap, bctbx_map_free_func freefunc) {
+ bctbx_iterator_t *it = bctbx_map_cchar_begin(mmap);
+ while(it) {
+ bctbx_pair_t *pair = bctbx_iterator_cchar_get_pair(it);
+ freefunc(bctbx_pair_cchar_get_second(pair));
+ it = bctbx_iterator_cchar_get_next(it);
+ }
+ bctbx_mmap_cchar_delete(mmap);
+}
template<typename T> bctbx_iterator_t *bctbx_map_insert_base(bctbx_map_t *map,const bctbx_pair_t *pair,bool_t returns_it) {
typename T::iterator it;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/bctoolbox.git
More information about the Pkg-voip-commits
mailing list