Skip to content
Snippets Groups Projects
Commit 0e4e9344 authored by Arne Goedeke's avatar Arne Goedeke
Browse files

block_alloc: memusage stats could overflow

parent 7a21e44b
No related branches found
No related tags found
No related merge requests found
...@@ -89,9 +89,13 @@ PMOD_EXPORT size_t ba_count(const struct block_allocator * a) { ...@@ -89,9 +89,13 @@ PMOD_EXPORT size_t ba_count(const struct block_allocator * a) {
} }
PMOD_EXPORT void ba_count_all(const struct block_allocator * a, size_t * num, size_t * size) { PMOD_EXPORT void ba_count_all(const struct block_allocator * a, size_t * num, size_t * size) {
if (a->size) {
size_t n = (a->l.blocks << (a->size-1)) - a->l.blocks; size_t n = (a->l.blocks << (a->size-1)) - a->l.blocks;
*num = n; *num = n;
*size = a->l.block_size * n; *size = a->l.block_size * n;
} else {
*num = *size = 0;
}
} }
static void ba_low_alloc(struct block_allocator * a) { static void ba_low_alloc(struct block_allocator * a) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment