From 8f53c184ea06bb1f060ce9ad30bc24893ff9c950 Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Wed, 9 Mar 2011 17:03:34 +0000 Subject: libxl: introduce flexarray_append_pair 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 Acked-by: Ian Jackson Committed-by: Ian Jackson --- tools/libxl/flexarray.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tools/libxl/flexarray.c') diff --git a/tools/libxl/flexarray.c b/tools/libxl/flexarray.c index 724eabd52f..c89c23e159 100644 --- a/tools/libxl/flexarray.c +++ b/tools/libxl/flexarray.c @@ -69,6 +69,14 @@ int flexarray_append(flexarray_t *array, void *ptr) return flexarray_set(array, array->count, ptr); } +int flexarray_append_pair(flexarray_t *array, void *ptr1, void *ptr2) +{ + int rc = flexarray_append(array, ptr1); + if (!rc) + rc = flexarray_append(array, ptr2); + return rc; +} + int flexarray_vappend(flexarray_t *array, ...) { va_list va; -- cgit v1.2.3