1 /* 2 * Copyright (C) 2009 Citrix Ltd. 3 * Author Vincent Hanquez <vincent.hanquez@eu.citrix.com> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU Lesser General Public License as published 7 * by the Free Software Foundation; version 2.1 only. with the special 8 * exception on linking described in file LICENSE. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 */ 15 16 #ifndef FLEXARRAY_H 17 #define FLEXARRAY_H 18 19 struct libxl__gc; 20 21 typedef struct flexarray { 22 int size; 23 int autogrow; 24 unsigned int count; 25 void **data; /* array of pointer */ 26 struct libxl__gc *gc; 27 } flexarray_t; 28 29 /* 30 * NOGC can be used with flexarrays, but flexarray_free will need to be called 31 * to free the struct. The content of the flexarray will not be freed through 32 * flexarray_free. 33 */ 34 _hidden flexarray_t *flexarray_make(struct libxl__gc *gc_opt, 35 int size, int autogrow); 36 _hidden void flexarray_free(flexarray_t *array); 37 _hidden void flexarray_grow(flexarray_t *array, int extents); 38 _hidden int flexarray_set(flexarray_t *array, unsigned int index, void *ptr); 39 _hidden int flexarray_append(flexarray_t *array, void *ptr); 40 _hidden int flexarray_append_pair(flexarray_t *array, void *ptr1, void *ptr2); 41 _hidden int flexarray_vappend(flexarray_t *array, ...); 42 _hidden int flexarray_get(flexarray_t *array, int index, void **ptr); 43 44 _hidden void **flexarray_contents(flexarray_t *array); 45 46 #endif 47 48 /* 49 * Local variables: 50 * mode: C 51 * c-basic-offset: 4 52 * indent-tabs-mode: nil 53 * End: 54 */ 55