Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- src/util/viralloc.c | 13 +++++-------- src/util/viralloc.h | 4 ++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/util/viralloc.c b/src/util/viralloc.c index 81f5ba9a09..cd7ae9e7d1 100644 --- a/src/util/viralloc.c +++ b/src/util/viralloc.c @@ -45,12 +45,11 @@ VIR_LOG_INIT("util.alloc"); * * Returns zero on success, aborts on OOM */ -int virReallocN(void *ptrptr, - size_t size, - size_t count) +void virReallocN(void *ptrptr, + size_t size, + size_t count) { *(void **)ptrptr = g_realloc_n(*(void**)ptrptr, size, count); - return 0; } /** @@ -76,8 +75,7 @@ void virExpandN(void *ptrptr, if (*countptr + add < *countptr) abort(); - if (virReallocN(ptrptr, size, *countptr + add) < 0) - abort(); + virReallocN(ptrptr, size, *countptr + add); memset(*(char **)ptrptr + (size * *countptr), 0, size * add); *countptr += add; } @@ -136,8 +134,7 @@ void virResizeN(void *ptrptr, void virShrinkN(void *ptrptr, size_t size, size_t *countptr, size_t toremove) { if (toremove < *countptr) { - if (virReallocN(ptrptr, size, *countptr -= toremove) < 0) - abort(); + virReallocN(ptrptr, size, *countptr -= toremove); } else { g_free(*((void **)ptrptr)); *((void **)ptrptr) = NULL; diff --git a/src/util/viralloc.h b/src/util/viralloc.h index 6051c91913..553d2951cf 100644 --- a/src/util/viralloc.h +++ b/src/util/viralloc.h @@ -34,7 +34,7 @@ */ /* Don't call these directly - use the macros below */ -int virReallocN(void *ptrptr, size_t size, size_t count) +void virReallocN(void *ptrptr, size_t size, size_t count) ATTRIBUTE_NONNULL(1); void virExpandN(void *ptrptr, size_t size, size_t *count, size_t add) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); @@ -61,7 +61,7 @@ int virDeleteElementsN(void *ptrptr, size_t size, size_t at, size_t *countptr, * * This macro is safe to use on arguments with side effects. * - * Returns 0 on success, aborts on OOM + * Aborts on OOM */ #define VIR_REALLOC_N(ptr, count) virReallocN(&(ptr), sizeof(*(ptr)), (count)) -- 2.31.0