mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2026-02-18 22:05:37 -05:00
some more work
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@23 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
993d1bce74
commit
382e7aefd4
14 changed files with 147 additions and 36 deletions
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "memblock.h"
|
||||
|
||||
unsigned n_blocks = 0;
|
||||
unsigned memblock_count = 0, memblock_total = 0;
|
||||
|
||||
struct memblock *memblock_new(size_t length) {
|
||||
struct memblock *b = malloc(sizeof(struct memblock)+length);
|
||||
|
|
@ -13,7 +13,8 @@ struct memblock *memblock_new(size_t length) {
|
|||
b->ref = 1;
|
||||
b->length = length;
|
||||
b->data = b+1;
|
||||
n_blocks++;
|
||||
memblock_count++;
|
||||
memblock_total += length;
|
||||
return b;
|
||||
}
|
||||
|
||||
|
|
@ -23,7 +24,8 @@ struct memblock *memblock_new_fixed(void *d, size_t length) {
|
|||
b->ref = 1;
|
||||
b->length = length;
|
||||
b->data = d;
|
||||
n_blocks++;
|
||||
memblock_count++;
|
||||
memblock_total += length;
|
||||
return b;
|
||||
}
|
||||
|
||||
|
|
@ -33,7 +35,8 @@ struct memblock *memblock_new_dynamic(void *d, size_t length) {
|
|||
b->ref = 1;
|
||||
b->length = length;
|
||||
b->data = d;
|
||||
n_blocks++;
|
||||
memblock_count++;
|
||||
memblock_total += length;
|
||||
return b;
|
||||
}
|
||||
|
||||
|
|
@ -50,8 +53,11 @@ void memblock_unref(struct memblock*b) {
|
|||
if (b->ref == 0) {
|
||||
if (b->type == MEMBLOCK_DYNAMIC)
|
||||
free(b->data);
|
||||
|
||||
memblock_count--;
|
||||
memblock_total -= b->length;
|
||||
|
||||
free(b);
|
||||
n_blocks--;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue