]> code.delx.au - pulseaudio/blob - src/pulsecore/dynarray.h
really create glitch-free branch
[pulseaudio] / src / pulsecore / dynarray.h
1 #ifndef foodynarrayhfoo
2 #define foodynarrayhfoo
3
4 /* $Id$ */
5
6 /***
7 This file is part of PulseAudio.
8
9 Copyright 2004-2006 Lennart Poettering
10
11 PulseAudio is free software; you can redistribute it and/or modify
12 it under the terms of the GNU Lesser General Public License as
13 published by the Free Software Foundation; either version 2.1 of the
14 License, or (at your option) any later version.
15
16 PulseAudio is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Lesser General Public License for more details.
20
21 You should have received a copy of the GNU Lesser General Public
22 License along with PulseAudio; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24 USA.
25 ***/
26
27 typedef struct pa_dynarray pa_dynarray;
28
29 /* Implementation of a simple dynamically sized array. The array
30 * expands if required, but doesn't shrink if possible. Memory
31 * management of the array's entries is the user's job. */
32
33 pa_dynarray* pa_dynarray_new(void);
34
35 /* Free the array calling the specified function for every entry in
36 * the array. The function may be NULL. */
37 void pa_dynarray_free(pa_dynarray* a, void (*func)(void *p, void *userdata), void *userdata);
38
39 /* Store p at position i in the array */
40 void pa_dynarray_put(pa_dynarray*a, unsigned i, void *p);
41
42 /* Store p a the first free position in the array. Returns the index
43 * of that entry. If entries are removed from the array their position
44 * are not filled any more by this function. */
45 unsigned pa_dynarray_append(pa_dynarray*a, void *p);
46
47 void *pa_dynarray_get(pa_dynarray*a, unsigned i);
48
49 unsigned pa_dynarray_size(pa_dynarray*a);
50
51 #endif