aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/common/memory_limitter.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-01-16 14:46:50 +0200
committerLasse Collin <lasse.collin@tukaani.org>2008-01-16 14:46:50 +0200
commit5b5b13c7bb8fde6331064d21f3ebde41072480c4 (patch)
treec502d3107e753fb687efcd684eaa906859da1fa2 /src/liblzma/common/memory_limitter.c
parentAdded ARRAY_SIZE(array) macro. (diff)
downloadxz-5b5b13c7bb8fde6331064d21f3ebde41072480c4.tar.xz
Added lzma_memlimit_count().
Diffstat (limited to '')
-rw-r--r--src/liblzma/common/memory_limitter.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/liblzma/common/memory_limitter.c b/src/liblzma/common/memory_limitter.c
index 19cdefc2..0983c82e 100644
--- a/src/liblzma/common/memory_limitter.c
+++ b/src/liblzma/common/memory_limitter.c
@@ -85,6 +85,25 @@ lzma_memlimit_used(const lzma_memlimit *mem)
}
+extern LZMA_API size_t
+lzma_memlimit_count(const lzma_memlimit *mem)
+{
+ // This is slow; we could have a counter in lzma_memlimit
+ // for fast version. I expect the primary use of this
+ // function to be limited to easy checking of memory leaks,
+ // in which this implementation is just fine.
+ size_t count = 0;
+ const lzma_memlimit_list *record = mem->list;
+
+ while (record != NULL) {
+ ++count;
+ record = record->next;
+ }
+
+ return count;
+}
+
+
extern LZMA_API void
lzma_memlimit_end(lzma_memlimit *mem, lzma_bool free_allocated)
{