[pulseaudio-commits] r1293 - in /trunk/src/pulsecore: memblock.c memblock.h
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Sat Aug 19 09:25:17 PDT 2006
Author: lennart
Date: Sat Aug 19 18:25:15 2006
New Revision: 1293
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1293&root=pulseaudio&view=rev
Log:
generate per-type memory block statistics
Modified:
trunk/src/pulsecore/memblock.c
trunk/src/pulsecore/memblock.h
Modified: trunk/src/pulsecore/memblock.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/memblock.c?rev=1293&root=pulseaudio&r1=1292&r2=1293&view=diff
==============================================================================
--- trunk/src/pulsecore/memblock.c (original)
+++ trunk/src/pulsecore/memblock.c Sat Aug 19 18:25:15 2006
@@ -121,6 +121,9 @@
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 @@
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,12 +358,20 @@
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 @@
new_data = mempool_slot_data(slot);
memcpy(new_data, b->data, b->length);
b->data = new_data;
- return;
+ goto finish;
}
}
@@ -382,6 +395,10 @@
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) {
Modified: trunk/src/pulsecore/memblock.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/memblock.h?rev=1293&root=pulseaudio&r1=1292&r2=1293&view=diff
==============================================================================
--- trunk/src/pulsecore/memblock.h (original)
+++ trunk/src/pulsecore/memblock.h Sat Aug 19 18:25:15 2006
@@ -40,6 +40,7 @@
PA_MEMBLOCK_USER, /* User supplied memory, to be freed with free_cb */
PA_MEMBLOCK_FIXED, /* data is a pointer to fixed memory that needs not to be freed */
PA_MEMBLOCK_IMPORTED, /* Memory is imported from another process via shm */
+ PA_MEMBLOCK_TYPE_MAX
} pa_memblock_type_t;
typedef struct pa_memblock pa_memblock;
@@ -84,6 +85,9 @@
unsigned n_too_large_for_pool;
unsigned n_pool_full;
+
+ unsigned n_allocated_by_type[PA_MEMBLOCK_TYPE_MAX];
+ unsigned n_accumulated_by_type[PA_MEMBLOCK_TYPE_MAX];
};
/* Allocate a new memory block of type PA_MEMBLOCK_MEMPOOL or PA_MEMBLOCK_APPENDED, depending on the size */
More information about the pulseaudio-commits
mailing list