summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/memblock.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-08-19 16:25:15 +0000
committerLennart Poettering <lennart@poettering.net>2006-08-19 16:25:15 +0000
commit57f0b08cc1c6be0afc4f563d41cacae7c5d820a9 (patch)
treea34716e970b28475ac50274ce78581d7dcf8e655 /src/pulsecore/memblock.c
parent16ff83f5c0acbd606f23090ebd4cba9ecaf502a7 (diff)
generate per-type memory block statistics
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1293 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/pulsecore/memblock.c')
-rw-r--r--src/pulsecore/memblock.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/pulsecore/memblock.c b/src/pulsecore/memblock.c
index 90494fb6..c34ddee5 100644
--- a/src/pulsecore/memblock.c
+++ b/src/pulsecore/memblock.c
@@ -121,6 +121,9 @@ static void stat_add(pa_memblock*b) {
b->pool->stat.n_imported++;
b->pool->stat.imported_size += b->length;
}
+
+ b->pool->stat.n_allocated_by_type[b->type]++;
+ b->pool->stat.n_accumulated_by_type[b->type]++;
}
static void stat_remove(pa_memblock *b) {
@@ -140,6 +143,8 @@ static void stat_remove(pa_memblock *b) {
b->pool->stat.n_imported --;
b->pool->stat.imported_size -= b->length;
}
+
+ b->pool->stat.n_allocated_by_type[b->type]--;
}
static pa_memblock *memblock_new_appended(pa_mempool *p, size_t length);
@@ -353,13 +358,21 @@ void pa_memblock_unref(pa_memblock*b) {
if (b->type == PA_MEMBLOCK_POOL_EXTERNAL)
pa_xfree(b);
+
+ break;
}
+
+ case PA_MEMBLOCK_TYPE_MAX:
+ default:
+ abort();
}
}
static void memblock_make_local(pa_memblock *b) {
assert(b);
+ b->pool->stat.n_allocated_by_type[b->type]--;
+
if (b->length <= b->pool->block_size - sizeof(struct mempool_slot)) {
struct mempool_slot *slot;
@@ -373,7 +386,7 @@ static void memblock_make_local(pa_memblock *b) {
new_data = mempool_slot_data(slot);
memcpy(new_data, b->data, b->length);
b->data = new_data;
- return;
+ goto finish;
}
}
@@ -382,6 +395,10 @@ static void memblock_make_local(pa_memblock *b) {
b->per_type.user.free_cb = pa_xfree;
b->read_only = 0;
b->data = pa_xmemdup(b->data, b->length);
+
+finish:
+ b->pool->stat.n_allocated_by_type[b->type]++;
+ b->pool->stat.n_accumulated_by_type[b->type]++;
}
void pa_memblock_unref_fixed(pa_memblock *b) {