]> code.delx.au - pulseaudio/blob - src/polypcore/dynarray.h
unhide padsp
[pulseaudio] / src / polypcore / dynarray.h
1 #ifndef foodynarrayhfoo
2 #define foodynarrayhfoo
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 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 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 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 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 typedef struct pa_dynarray pa_dynarray;
26
27 /* Implementation of a simple dynamically sized array. The array
28 * expands if required, but doesn't shrink if possible. Memory
29 * management of the array's entries is the user's job. */
30
31 pa_dynarray* pa_dynarray_new(void);
32
33 /* Free the array calling the specified function for every entry in
34 * the array. The function may be NULL. */
35 void pa_dynarray_free(pa_dynarray* a, void (*func)(void *p, void *userdata), void *userdata);
36
37 /* Store p at position i in the array */
38 void pa_dynarray_put(pa_dynarray*a, unsigned i, void *p);
39
40 /* Store p a the first free position in the array. Returns the index
41 * of that entry. If entries are removed from the array their position
42 * are not filled any more by this function. */
43 unsigned pa_dynarray_append(pa_dynarray*a, void *p);
44
45 void *pa_dynarray_get(pa_dynarray*a, unsigned i);
46
47 unsigned pa_dynarray_size(pa_dynarray*a);
48
49 #endif