mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 18:21:39 +01:00
Introduce flexarray_append_pair: a simple syntactic sugar to add a pair of pointers to a flexarray, very useful when adding pairs of strings to xenstore. Replace flexarray_vappend calls (and one pair of flexarray_append) with flexarray_append_pair calls when dealing with flexarrays that are going to be used with libxl__xs_kvs_of_flexarray: NULL is a valid pointer value in these cases while flexarray_vappend uses NULL as vargs terminator, so the old code is buggy. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
38 lines
1.4 KiB
C
38 lines
1.4 KiB
C
/*
|
|
* Copyright (C) 2009 Citrix Ltd.
|
|
* Author Vincent Hanquez <vincent.hanquez@eu.citrix.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published
|
|
* by the Free Software Foundation; version 2.1 only. with the special
|
|
* exception on linking described in file LICENSE.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Lesser General Public License for more details.
|
|
*/
|
|
|
|
#ifndef FLEXARRAY_H
|
|
#define FLEXARRAY_H
|
|
|
|
typedef struct flexarray {
|
|
int size;
|
|
int autogrow;
|
|
unsigned int count;
|
|
void **data; /* array of pointer */
|
|
} flexarray_t;
|
|
|
|
_hidden flexarray_t *flexarray_make(int size, int autogrow);
|
|
_hidden void flexarray_free(flexarray_t *array);
|
|
_hidden int flexarray_grow(flexarray_t *array, int extents);
|
|
_hidden int flexarray_set(flexarray_t *array, unsigned int index, void *ptr);
|
|
_hidden int flexarray_append(flexarray_t *array, void *ptr);
|
|
_hidden int flexarray_append_pair(flexarray_t *array, void *ptr1, void *ptr2);
|
|
_hidden int flexarray_vappend(flexarray_t *array, ...);
|
|
_hidden int flexarray_get(flexarray_t *array, int index, void **ptr);
|
|
|
|
_hidden void **flexarray_contents(flexarray_t *array);
|
|
|
|
#endif
|