The functions are left returning an "int" to avoid an immediate big-bang cleanup. They'll simply never return anything other than 0, except for virInsertN which can still return an error if the requested insertion index is out of range. Interestingly in that case, the _QUIET function would none the less report an error. Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx> Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx> --- src/util/viralloc.c | 203 +++++++++++--------------------------------- src/util/viralloc.h | 133 ++++++++++------------------- 2 files changed, 93 insertions(+), 243 deletions(-) diff --git a/src/util/viralloc.c b/src/util/viralloc.c index 5a0adcc706..10a8d0fb73 100644 --- a/src/util/viralloc.c +++ b/src/util/viralloc.c @@ -35,33 +35,20 @@ VIR_LOG_INIT("util.alloc"); * virAlloc: * @ptrptr: pointer to pointer for address of allocated memory * @size: number of bytes to allocate - * @report: whether to report OOM error, if there is one - * @domcode: error domain code - * @filename: caller's filename - * @funcname: caller's funcname - * @linenr: caller's line number * * Allocate 'size' bytes of memory. Return the address of the * allocated memory in 'ptrptr'. The newly allocated memory is - * filled with zeros. If @report is true, OOM errors are - * reported automatically. + * filled with zeros. * - * Returns -1 on failure to allocate, zero on success + * Returns zero on success, aborts on OOM */ int virAlloc(void *ptrptr, - size_t size, - bool report, - int domcode, - const char *filename, - const char *funcname, - size_t linenr) + size_t size) { *(void **)ptrptr = calloc(1, size); - if (*(void **)ptrptr == NULL) { - if (report) - virReportOOMErrorFull(domcode, filename, funcname, linenr); - return -1; - } + if (*(void **)ptrptr == NULL) + abort(); + return 0; } @@ -70,35 +57,22 @@ int virAlloc(void *ptrptr, * @ptrptr: pointer to pointer for address of allocated memory * @size: number of bytes to allocate * @count: number of elements to allocate - * @report: whether to report OOM error, if there is one - * @domcode: error domain code - * @filename: caller's filename - * @funcname: caller's funcname - * @linenr: caller's line number * * Allocate an array of memory 'count' elements long, * each with 'size' bytes. Return the address of the * allocated memory in 'ptrptr'. The newly allocated - * memory is filled with zeros. If @report is true, - * OOM errors are reported automatically. + * memory is filled with zeros. * - * Returns -1 on failure to allocate, zero on success + * Returns zero on success, aborts on OOM */ int virAllocN(void *ptrptr, size_t size, - size_t count, - bool report, - int domcode, - const char *filename, - const char *funcname, - size_t linenr) + size_t count) { *(void**)ptrptr = calloc(count, size); - if (*(void**)ptrptr == NULL) { - if (report) - virReportOOMErrorFull(domcode, filename, funcname, linenr); - return -1; - } + if (*(void**)ptrptr == NULL) + abort(); + return 0; } @@ -107,44 +81,28 @@ int virAllocN(void *ptrptr, * @ptrptr: pointer to pointer for address of allocated memory * @size: number of bytes to allocate * @count: number of elements in array - * @report: whether to report OOM error, if there is one - * @domcode: error domain code - * @filename: caller's filename - * @funcname: caller's funcname - * @linenr: caller's line number * * Resize the block of memory in 'ptrptr' to be an array of * 'count' elements, each 'size' bytes in length. Update 'ptrptr' * with the address of the newly allocated memory. On failure, * 'ptrptr' is not changed and still points to the original memory * block. Any newly allocated memory in 'ptrptr' is uninitialized. - * If @report is true, OOM errors are reported automatically. * - * Returns -1 on failure to allocate, zero on success + * Returns zero on success, aborts on OOM */ int virReallocN(void *ptrptr, size_t size, - size_t count, - bool report, - int domcode, - const char *filename, - const char *funcname, - size_t linenr) + size_t count) { void *tmp; - if (xalloc_oversized(count, size)) { - if (report) - virReportOOMErrorFull(domcode, filename, funcname, linenr); - errno = ENOMEM; - return -1; - } + if (xalloc_oversized(count, size)) + abort(); + tmp = realloc(*(void**)ptrptr, size * count); - if (!tmp && ((size * count) != 0)) { - if (report) - virReportOOMErrorFull(domcode, filename, funcname, linenr); - return -1; - } + if (!tmp && ((size * count) != 0)) + abort(); + *(void**)ptrptr = tmp; return 0; } @@ -155,46 +113,28 @@ int virReallocN(void *ptrptr, * @size: number of bytes per element * @countptr: pointer to number of elements in array * @add: number of elements to add - * @report: whether to report OOM error, if there is one - * @domcode: error domain code - * @filename: caller's filename - * @funcname: caller's funcname - * @linenr: caller's line number * * Resize the block of memory in 'ptrptr' to be an array of * '*countptr' + 'add' elements, each 'size' bytes in length. * Update 'ptrptr' and 'countptr' with the details of the newly * allocated memory. On failure, 'ptrptr' and 'countptr' are not * changed. Any newly allocated memory in 'ptrptr' is zero-filled. - * If @report is true, OOM errors are reported automatically. * - * Returns -1 on failure to allocate, zero on success + * Returns zero on success, aborts on OOM */ int virExpandN(void *ptrptr, size_t size, size_t *countptr, - size_t add, - bool report, - int domcode, - const char *filename, - const char *funcname, - size_t linenr) + size_t add) { - int ret; + if (*countptr + add < *countptr) + abort(); - if (*countptr + add < *countptr) { - if (report) - virReportOOMErrorFull(domcode, filename, funcname, linenr); - errno = ENOMEM; - return -1; - } - ret = virReallocN(ptrptr, size, *countptr + add, report, - domcode, filename, funcname, linenr); - if (ret == 0) { - memset(*(char **)ptrptr + (size * *countptr), 0, size * add); - *countptr += add; - } - return ret; + if (virReallocN(ptrptr, size, *countptr + add) < 0) + abort(); + memset(*(char **)ptrptr + (size * *countptr), 0, size * add); + *countptr += add; + return 0; } /** @@ -204,50 +144,34 @@ int virExpandN(void *ptrptr, * @allocptr: pointer to number of elements allocated in array * @count: number of elements currently used in array * @add: minimum number of additional elements to support in array - * @report: whether to report OOM error, if there is one - * @domcode: error domain code - * @filename: caller's filename - * @funcname: caller's funcname - * @linenr: caller's line number * * If 'count' + 'add' is larger than '*allocptr', then resize the * block of memory in 'ptrptr' to be an array of at least 'count' + * 'add' elements, each 'size' bytes in length. Update 'ptrptr' and * 'allocptr' with the details of the newly allocated memory. On * failure, 'ptrptr' and 'allocptr' are not changed. Any newly - * allocated memory in 'ptrptr' is zero-filled. If @report is true, - * OOM errors are reported automatically. - * + * allocated memory in 'ptrptr' is zero-filled. * - * Returns -1 on failure to allocate, zero on success + * Returns zero on success, aborts on OOM */ int virResizeN(void *ptrptr, size_t size, size_t *allocptr, size_t count, - size_t add, - bool report, - int domcode, - const char *filename, - const char *funcname, - size_t linenr) + size_t add) { size_t delta; - if (count + add < count) { - if (report) - virReportOOMErrorFull(domcode, filename, funcname, linenr); - errno = ENOMEM; - return -1; - } + if (count + add < count) + abort(); + if (count + add <= *allocptr) return 0; delta = count + add - *allocptr; if (delta < *allocptr / 2) delta = *allocptr / 2; - return virExpandN(ptrptr, size, allocptr, delta, report, - domcode, filename, funcname, linenr); + return virExpandN(ptrptr, size, allocptr, delta); } /** @@ -266,8 +190,8 @@ int virResizeN(void *ptrptr, void virShrinkN(void *ptrptr, size_t size, size_t *countptr, size_t toremove) { if (toremove < *countptr) { - ignore_value(virReallocN(ptrptr, size, *countptr -= toremove, - false, 0, NULL, NULL, 0)); + if (virReallocN(ptrptr, size, *countptr -= toremove) < 0) + abort(); } else { virFree(ptrptr); *countptr = 0; @@ -290,11 +214,6 @@ void virShrinkN(void *ptrptr, size_t size, size_t *countptr, size_t toremove) * @inPlace: false if we should expand the allocated memory before * moving, true if we should assume someone else *has * already* done that. - * @report: whether to report OOM error, if there is one - * @domcode: error domain code - * @filename: caller's filename - * @funcname: caller's funcname - * @linenr: caller's line number * * Re-allocate an array of *countptr elements, each sizeof(*ptrptr) bytes * long, to be *countptr+add elements long, then appropriately move @@ -303,8 +222,7 @@ void virShrinkN(void *ptrptr, size_t size, size_t *countptr, size_t toremove) * allocated memory in *ptrptr and the new size in *countptr. If * newelems is NULL, the new elements at ptrptr[at] are instead filled * with zero. at must be between [0,*countptr], except that -1 is - * treated the same as *countptr for convenience. If @report is true, - * OOM errors are reported automatically. + * treated the same as *countptr for convenience. * * Returns -1 on failure, 0 on success */ @@ -312,12 +230,7 @@ int virInsertElementsN(void *ptrptr, size_t size, size_t at, size_t *countptr, size_t add, void *newelems, - bool clearOriginal, bool inPlace, - bool report, - int domcode, - const char *filename, - const char *funcname, - size_t linenr) + bool clearOriginal, bool inPlace) { if (at == -1) { at = *countptr; @@ -330,9 +243,9 @@ virInsertElementsN(void *ptrptr, size_t size, size_t at, if (inPlace) { *countptr += add; - } else if (virExpandN(ptrptr, size, countptr, add, report, - domcode, filename, funcname, linenr) < 0) { - return -1; + } else { + if (virExpandN(ptrptr, size, countptr, add) < 0) + abort(); } /* memory was successfully re-allocated. Move up all elements from @@ -407,11 +320,6 @@ virDeleteElementsN(void *ptrptr, size_t size, size_t at, * @struct_size: size of initial struct * @element_size: size of array elements * @count: number of array elements to allocate - * @report: whether to report OOM error, if there is one - * @domcode: error domain code - * @filename: caller's filename - * @funcname: caller's funcname - * @linenr: caller's line number * * Allocate struct_size bytes plus an array of 'count' elements, each * of size element_size. This sort of allocation is useful for @@ -420,37 +328,24 @@ virDeleteElementsN(void *ptrptr, size_t size, size_t at, * The caller of this type of API is expected to know the length of * the array that will be returned and allocate a suitable buffer to * contain the returned data. C99 refers to these variable length - * objects as structs containing flexible array members. If @report - * is true, OOM errors are reported automatically. + * objects as structs containing flexible array members. * * Returns -1 on failure, 0 on success */ int virAllocVar(void *ptrptr, size_t struct_size, size_t element_size, - size_t count, - bool report, - int domcode, - const char *filename, - const char *funcname, - size_t linenr) + size_t count) { size_t alloc_size = 0; - if (VIR_ALLOC_VAR_OVERSIZED(struct_size, count, element_size)) { - if (report) - virReportOOMErrorFull(domcode, filename, funcname, linenr); - errno = ENOMEM; - return -1; - } + if (VIR_ALLOC_VAR_OVERSIZED(struct_size, count, element_size)) + abort(); alloc_size = struct_size + (element_size * count); *(void **)ptrptr = calloc(1, alloc_size); - if (*(void **)ptrptr == NULL) { - if (report) - virReportOOMErrorFull(domcode, filename, funcname, linenr); - return -1; - } + if (*(void **)ptrptr == NULL) + abort(); return 0; } diff --git a/src/util/viralloc.h b/src/util/viralloc.h index 3e169e272c..78f72a6c6a 100644 --- a/src/util/viralloc.h +++ b/src/util/viralloc.h @@ -44,35 +44,26 @@ /* Don't call these directly - use the macros below */ -int virAlloc(void *ptrptr, size_t size, bool report, int domcode, - const char *filename, const char *funcname, size_t linenr) +int virAlloc(void *ptrptr, size_t size) ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1); -int virAllocN(void *ptrptr, size_t size, size_t count, bool report, int domcode, - const char *filename, const char *funcname, size_t linenr) +int virAllocN(void *ptrptr, size_t size, size_t count) ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1); -int virReallocN(void *ptrptr, size_t size, size_t count, bool report, int domcode, - const char *filename, const char *funcname, size_t linenr) +int virReallocN(void *ptrptr, size_t size, size_t count) ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1); -int virExpandN(void *ptrptr, size_t size, size_t *count, size_t add, bool report, - int domcode, const char *filename, const char *funcname, size_t linenr) +int virExpandN(void *ptrptr, size_t size, size_t *count, size_t add) ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); -int virResizeN(void *ptrptr, size_t size, size_t *alloc, size_t count, size_t desired, - bool report, int domcode, const char *filename, - const char *funcname, size_t linenr) +int virResizeN(void *ptrptr, size_t size, size_t *alloc, size_t count, size_t desired) ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); void virShrinkN(void *ptrptr, size_t size, size_t *count, size_t toremove) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); int virInsertElementsN(void *ptrptr, size_t size, size_t at, size_t *countptr, size_t add, void *newelem, - bool clearOriginal, bool inPlace, bool report, int domcode, - const char *filename, const char *funcname, size_t linenr) + bool clearOriginal, bool inPlace) ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4); int virDeleteElementsN(void *ptrptr, size_t size, size_t at, size_t *countptr, size_t toremove, bool inPlace) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4); -int virAllocVar(void *ptrptr, size_t struct_size, size_t element_size, size_t count, - bool report, int domcode, const char *filename, - const char *funcname, size_t linenr) +int virAllocVar(void *ptrptr, size_t struct_size, size_t element_size, size_t count) ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1); void virFree(void *ptrptr) ATTRIBUTE_NONNULL(1); @@ -91,10 +82,9 @@ void virDisposeString(char **strptr) * * This macro is safe to use on arguments with side effects. * - * Returns -1 on failure (with OOM error reported), 0 on success + * Returns 0 on success, aborts on OOM */ -#define VIR_ALLOC(ptr) virAlloc(&(ptr), sizeof(*(ptr)), true, VIR_FROM_THIS, \ - __FILE__, __FUNCTION__, __LINE__) +#define VIR_ALLOC(ptr) virAlloc(&(ptr), sizeof(*(ptr))) /** * VIR_ALLOC_QUIET: @@ -106,9 +96,9 @@ void virDisposeString(char **strptr) * * This macro is safe to use on arguments with side effects. * - * Returns -1 on failure, 0 on success + * Returns 0 on success, aborts on OOM */ -#define VIR_ALLOC_QUIET(ptr) virAlloc(&(ptr), sizeof(*(ptr)), false, 0, NULL, NULL, 0) +#define VIR_ALLOC_QUIET(ptr) VIR_ALLOC(ptr) /** * VIR_ALLOC_N: @@ -121,10 +111,9 @@ void virDisposeString(char **strptr) * * This macro is safe to use on arguments with side effects. * - * Returns -1 on failure (with OOM error reported), 0 on success + * Returns 0 on success, aborts on OOM */ -#define VIR_ALLOC_N(ptr, count) virAllocN(&(ptr), sizeof(*(ptr)), (count), true, \ - VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__) +#define VIR_ALLOC_N(ptr, count) virAllocN(&(ptr), sizeof(*(ptr)), (count)) /** * VIR_ALLOC_N_QUIET: @@ -137,10 +126,9 @@ void virDisposeString(char **strptr) * * This macro is safe to use on arguments with side effects. * - * Returns -1 on failure, 0 on success + * Returns 0 on success, aborts on OOM */ -#define VIR_ALLOC_N_QUIET(ptr, count) virAllocN(&(ptr), sizeof(*(ptr)), (count), \ - false, 0, NULL, NULL, 0) +#define VIR_ALLOC_N_QUIET(ptr, count) VIR_ALLOC_N(ptr, count) /** * VIR_REALLOC_N: @@ -153,11 +141,9 @@ void virDisposeString(char **strptr) * * This macro is safe to use on arguments with side effects. * - * Returns -1 on failure (with OOM error reported), 0 on success + * Returns 0 on success, aborts on OOM */ -#define VIR_REALLOC_N(ptr, count) virReallocN(&(ptr), sizeof(*(ptr)), (count), \ - true, VIR_FROM_THIS, __FILE__, \ - __FUNCTION__, __LINE__) +#define VIR_REALLOC_N(ptr, count) virReallocN(&(ptr), sizeof(*(ptr)), (count)) /** * VIR_REALLOC_N_QUIET: @@ -170,10 +156,9 @@ void virDisposeString(char **strptr) * * This macro is safe to use on arguments with side effects. * - * Returns -1 on failure, 0 on success + * Returns 0 on success, aborts on OOM */ -#define VIR_REALLOC_N_QUIET(ptr, count) virReallocN(&(ptr), sizeof(*(ptr)), (count), \ - false, 0, NULL, NULL, 0) +#define VIR_REALLOC_N_QUIET(ptr, count) VIR_REALLOC_N(ptr, count) /** * VIR_EXPAND_N: @@ -188,11 +173,9 @@ void virDisposeString(char **strptr) * * This macro is safe to use on arguments with side effects. * - * Returns -1 on failure (with OOM error reported), 0 on success + * Returns 0 on success, aborts on OOM */ -#define VIR_EXPAND_N(ptr, count, add) \ - virExpandN(&(ptr), sizeof(*(ptr)), &(count), add, true, VIR_FROM_THIS, \ - __FILE__, __FUNCTION__, __LINE__) +#define VIR_EXPAND_N(ptr, count, add) virExpandN(&(ptr), sizeof(*(ptr)), &(count), add) /** * VIR_EXPAND_N_QUIET: @@ -207,10 +190,9 @@ void virDisposeString(char **strptr) * * This macro is safe to use on arguments with side effects. * - * Returns -1 on failure, 0 on success + * Returns 0 on success, aborts on OOM */ -#define VIR_EXPAND_N_QUIET(ptr, count, add) \ - virExpandN(&(ptr), sizeof(*(ptr)), &(count), add, false, 0, NULL, NULL, 0) +#define VIR_EXPAND_N_QUIET(ptr, count, add) VIR_EXPAND_N(ptr, count, add) /** * VIR_RESIZE_N: @@ -232,11 +214,10 @@ void virDisposeString(char **strptr) * * This macro is safe to use on arguments with side effects. * - * Returns -1 on failure (with OOM error reported), 0 on success + * Returns 0 on success, aborts on OOM */ #define VIR_RESIZE_N(ptr, alloc, count, add) \ - virResizeN(&(ptr), sizeof(*(ptr)), &(alloc), count, add, true, \ - VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__) + virResizeN(&(ptr), sizeof(*(ptr)), &(alloc), count, add) /** * VIR_RESIZE_N_QUIET: @@ -258,11 +239,9 @@ void virDisposeString(char **strptr) * * This macro is safe to use on arguments with side effects. * - * Returns -1 on failure, 0 on success + * Returns 0 on success, aborts on OOM */ -#define VIR_RESIZE_N_QUIET(ptr, alloc, count, add) \ - virResizeN(&(ptr), sizeof(*(ptr)), &(alloc), count, add, \ - false, 0, NULL, NULL, 0) +#define VIR_RESIZE_N_QUIET(ptr, alloc, count, add) VIR_RESIZE_N(ptr, alloc, count, add) /** * VIR_SHRINK_N: @@ -359,38 +338,26 @@ void virDisposeString(char **strptr) */ #define VIR_INSERT_ELEMENT(ptr, at, count, newelem) \ virInsertElementsN(&(ptr), sizeof(*(ptr)), at, &(count), \ - VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, false, \ - true, VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__) + VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, false) #define VIR_INSERT_ELEMENT_COPY(ptr, at, count, newelem) \ virInsertElementsN(&(ptr), sizeof(*(ptr)), at, &(count), \ - VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, false, \ - true, VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__) + VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, false) #define VIR_INSERT_ELEMENT_INPLACE(ptr, at, count, newelem) \ virInsertElementsN(&(ptr), sizeof(*(ptr)), at, &(count), \ - VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, true, \ - true, VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__) + VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, true) #define VIR_INSERT_ELEMENT_COPY_INPLACE(ptr, at, count, newelem) \ virInsertElementsN(&(ptr), sizeof(*(ptr)), at, &(count), \ - VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, true, \ - true, VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__) + VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, true) /* Quiet version of macros above */ #define VIR_INSERT_ELEMENT_QUIET(ptr, at, count, newelem) \ - virInsertElementsN(&(ptr), sizeof(*(ptr)), at, &(count), \ - VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, false, \ - false, 0, NULL, NULL, 0) + VIR_INSERT_ELEMENT(ptr, at, count, newelem) #define VIR_INSERT_ELEMENT_COPY_QUIET(ptr, at, count, newelem) \ - virInsertElementsN(&(ptr), sizeof(*(ptr)), at, &(count), \ - VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, false, \ - false, 0, NULL, NULL, 0) + VIR_INSERT_ELEMENT_COPY(ptr, at, count, newelem) #define VIR_INSERT_ELEMENT_INPLACE_QUIET(ptr, at, count, newelem) \ - virInsertElementsN(&(ptr), sizeof(*(ptr)), at, &(count), \ - VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, true, \ - false, 0, NULL, NULL, 0) + VIR_INSERT_ELEMENT_INPLACE(ptr, at, count, newelem) #define VIR_INSERT_ELEMENT_COPY_INPLACE_QUIET(ptr, at, count, newelem) \ - virInsertElementsN(&(ptr), sizeof(*(ptr)), at, &(count), \ - VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, true, \ - false, 0, NULL, NULL, 0) + VIR_INSERT_ELEMENT_COPY_INPLACE(ptr, at, count, newelem) /** * VIR_APPEND_ELEMENT: @@ -429,34 +396,24 @@ void virDisposeString(char **strptr) */ #define VIR_APPEND_ELEMENT(ptr, count, newelem) \ virInsertElementsN(&(ptr), sizeof(*(ptr)), -1, &(count), \ - VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, false, \ - true, VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__) + VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, false) #define VIR_APPEND_ELEMENT_COPY(ptr, count, newelem) \ virInsertElementsN(&(ptr), sizeof(*(ptr)), -1, &(count), \ - VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, false, \ - true, VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__) + VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, false) #define VIR_APPEND_ELEMENT_INPLACE(ptr, count, newelem) \ ignore_value(virInsertElementsN(&(ptr), sizeof(*(ptr)), -1, &(count), \ VIR_TYPEMATCH(ptr, &(newelem)), \ - &(newelem), true, true, false, \ - VIR_FROM_THIS, __FILE__, \ - __FUNCTION__, __LINE__)) + &(newelem), true, true)) #define VIR_APPEND_ELEMENT_COPY_INPLACE(ptr, count, newelem) \ ignore_value(virInsertElementsN(&(ptr), sizeof(*(ptr)), -1, &(count), \ VIR_TYPEMATCH(ptr, &(newelem)), \ - &(newelem), false, true, false, \ - VIR_FROM_THIS, __FILE__, \ - __FUNCTION__, __LINE__)) + &(newelem), false, true)) /* Quiet version of macros above */ #define VIR_APPEND_ELEMENT_QUIET(ptr, count, newelem) \ - virInsertElementsN(&(ptr), sizeof(*(ptr)), -1, &(count), \ - VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, false, \ - false, 0, NULL, NULL, 0) + VIR_APPEND_ELEMENT(ptr, count, newelem) #define VIR_APPEND_ELEMENT_COPY_QUIET(ptr, count, newelem) \ - virInsertElementsN(&(ptr), sizeof(*(ptr)), -1, &(count), \ - VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, false, \ - false, 0, NULL, NULL, 0) + VIR_APPEND_ELEMENT_COPY(ptr, count, newelem) /** * VIR_DELETE_ELEMENT: @@ -510,11 +467,10 @@ void virDisposeString(char **strptr) * * This macro is safe to use on arguments with side effects. * - * Returns -1 on failure (with OOM error reported), 0 on success + * Returns 0 on success, aborts on OOM */ #define VIR_ALLOC_VAR(ptr, type, count) \ - virAllocVar(&(ptr), sizeof(*(ptr)), sizeof(type), (count), true, \ - VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__) + virAllocVar(&(ptr), sizeof(*(ptr)), sizeof(type), (count)) /** * VIR_ALLOC_VAR_QUIET: @@ -535,8 +491,7 @@ void virDisposeString(char **strptr) * * Returns -1 on failure, 0 on success */ -#define VIR_ALLOC_VAR_QUIET(ptr, type, count) \ - virAllocVar(&(ptr), sizeof(*(ptr)), sizeof(type), (count), false, 0, NULL, NULL, 0) +#define VIR_ALLOC_VAR_QUIET(ptr, type, count) VIR_ALLOC_VAR(ptr, type, count) /** * VIR_FREE: -- 2.21.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list