]> code.delx.au - pulseaudio/blob - src/pulsecore/dynarray.h
remap: Change remapping function argument type from void to int16_t / float as approp...
[pulseaudio] / src / pulsecore / dynarray.h
1 #ifndef foopulsecoredynarrayhfoo
2 #define foopulsecoredynarrayhfoo
3
4 /***
5 This file is part of PulseAudio.
6
7 Copyright 2004-2008 Lennart Poettering
8
9 PulseAudio is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as
11 published by the Free Software Foundation; either version 2.1 of the
12 License, or (at your option) any later version.
13
14 PulseAudio 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 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with PulseAudio; 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 <pulse/def.h>
26
27 typedef struct pa_dynarray pa_dynarray;
28
29 /* Implementation of a simple dynamically sized array for storing pointers.
30 *
31 * When the array is created, a free callback can be provided, which will be
32 * then used when removing items from the array and when freeing the array. If
33 * the free callback is not provided, the memory management of the stored items
34 * is the responsibility of the array user. If there is need to remove items
35 * from the array without freeing them, while also having the free callback
36 * set, the functions with "steal" in their name can be used.
37 *
38 * Removing items from the middle of the array causes the subsequent items to
39 * be moved to fill the gap, so it's not efficient with large arrays. If the
40 * order of the array is not important, however, functions with "fast" in their
41 * name can be used, in which case the gap is filled by moving only the last
42 * item(s). XXX: Currently there are no functions with "fast" in their name,
43 * but such functions will be added if they are ever needed.
44 *
45 * The array doesn't support storing NULL pointers. */
46
47 pa_dynarray* pa_dynarray_new(pa_free_cb_t free_cb);
48 void pa_dynarray_free(pa_dynarray *array);
49
50 void pa_dynarray_append(pa_dynarray *array, void *p);
51 void *pa_dynarray_get(pa_dynarray *array, unsigned i);
52
53 /* Returns the removed item, or NULL if the array is empty. */
54 void *pa_dynarray_steal_last(pa_dynarray *array);
55
56 unsigned pa_dynarray_size(pa_dynarray *array);
57
58 #endif