]> code.delx.au - pulseaudio/blob - polyp/memblock.h
949a0a08c471e7daaa6d3c9204d4ad0902a7812b
[pulseaudio] / polyp / memblock.h
1 #ifndef foomemblockhfoo
2 #define foomemblockhfoo
3
4 /* $Id$ */
5
6 /***
7 This file is part of polypaudio.
8
9 polypaudio is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published
11 by the Free Software Foundation; either version 2 of the License,
12 or (at your option) any later version.
13
14 polypaudio is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with polypaudio; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 USA.
23 ***/
24
25 #include <sys/types.h>
26 #include <inttypes.h>
27
28 enum pa_memblock_type { PA_MEMBLOCK_FIXED, PA_MEMBLOCK_APPENDED, PA_MEMBLOCK_DYNAMIC, PA_MEMBLOCK_USER };
29
30 struct pa_memblock_stat;
31
32 struct pa_memblock {
33 enum pa_memblock_type type;
34 unsigned ref;
35 size_t length;
36 void *data;
37 void (*free_cb)(void *p);
38 struct pa_memblock_stat *stat;
39 };
40
41 struct pa_memblock *pa_memblock_new(size_t length, struct pa_memblock_stat*s);
42 struct pa_memblock *pa_memblock_new_fixed(void *data, size_t length, struct pa_memblock_stat*s);
43 struct pa_memblock *pa_memblock_new_dynamic(void *data, size_t length, struct pa_memblock_stat*s);
44 struct pa_memblock *pa_memblock_new_user(void *data, size_t length, void (*free_cb)(void *p), struct pa_memblock_stat*s);
45
46 void pa_memblock_unref(struct pa_memblock*b);
47 struct pa_memblock* pa_memblock_ref(struct pa_memblock*b);
48
49 void pa_memblock_unref_fixed(struct pa_memblock*b);
50
51 struct pa_memblock_stat {
52 int ref;
53 unsigned total;
54 unsigned total_size;
55 unsigned allocated;
56 unsigned allocated_size;
57 };
58
59 struct pa_memblock_stat* pa_memblock_stat_new(void);
60 void pa_memblock_stat_unref(struct pa_memblock_stat *s);
61 struct pa_memblock_stat * pa_memblock_stat_ref(struct pa_memblock_stat *s);
62
63 #endif