diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2023-07-11 14:06:33 -0700 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2023-07-11 14:06:33 -0700 |
| commit | 18cd5f331b8d043a7f9c4d161f2319dc456dfcc9 (patch) | |
| tree | 1d91cfbce70220953882713a81ad1157eba1f884 | |
| parent | 7529ab103b0c20220a5bbe2f2ce5511e04e9acda (diff) | |
| download | libbu++-18cd5f331b8d043a7f9c4d161f2319dc456dfcc9.tar.gz libbu++-18cd5f331b8d043a7f9c4d161f2319dc456dfcc9.tar.bz2 libbu++-18cd5f331b8d043a7f9c4d161f2319dc456dfcc9.tar.xz libbu++-18cd5f331b8d043a7f9c4d161f2319dc456dfcc9.zip | |
Fixed cachebase memory leak.
Diffstat (limited to '')
| -rw-r--r-- | default.bld | 4 | ||||
| -rw-r--r-- | src/unstable/cachebase.h | 11 |
2 files changed, 13 insertions, 2 deletions
diff --git a/default.bld b/default.bld index 2077185..8f21f6c 100644 --- a/default.bld +++ b/default.bld | |||
| @@ -16,8 +16,8 @@ include "gensigs.bld"; | |||
| 16 | CXXFLAGS += "-ggdb -W -Wall -I."; | 16 | CXXFLAGS += "-ggdb -W -Wall -I."; |
| 17 | 17 | ||
| 18 | // Deep memory checks | 18 | // Deep memory checks |
| 19 | CXXFLAGS += "-fsanitize=address -fno-omit-frame-pointer"; | 19 | // CXXFLAGS += "-fsanitize=address -fno-omit-frame-pointer"; |
| 20 | LDFLAGS += "-fsanitize=address -fno-omit-frame-pointer"; | 20 | // LDFLAGS += "-fsanitize=address -fno-omit-frame-pointer"; |
| 21 | 21 | ||
| 22 | //CXXFLAGS += "-pg"; | 22 | //CXXFLAGS += "-pg"; |
| 23 | //LDFLAGS += "-pg"; | 23 | //LDFLAGS += "-pg"; |
diff --git a/src/unstable/cachebase.h b/src/unstable/cachebase.h index 7a54465..762aca2 100644 --- a/src/unstable/cachebase.h +++ b/src/unstable/cachebase.h | |||
| @@ -34,6 +34,13 @@ namespace Bu | |||
| 34 | { | 34 | { |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | virtual ~CacheEntry() | ||
| 38 | { | ||
| 39 | mEntry.lock(); | ||
| 40 | delete pObject; | ||
| 41 | mEntry.unlock(); | ||
| 42 | } | ||
| 43 | |||
| 37 | public: | 44 | public: |
| 38 | int getRefCount() const | 45 | int getRefCount() const |
| 39 | { | 46 | { |
| @@ -386,6 +393,10 @@ namespace Bu | |||
| 386 | 393 | ||
| 387 | virtual ~CacheBase() | 394 | virtual ~CacheBase() |
| 388 | { | 395 | { |
| 396 | for( typename CacheEntryHash::iterator i = hCacheEntry.begin(); i; i++ ) | ||
| 397 | { | ||
| 398 | delete i.getValue(); | ||
| 399 | } | ||
| 389 | } | 400 | } |
| 390 | 401 | ||
| 391 | typedef CacheEntry<keytype, obtype> Entry; | 402 | typedef CacheEntry<keytype, obtype> Entry; |
