[libvirt PATCH 8/8] util: delete VIR_ALLOC and VIR_ALLOC_N

Ján Tomko jtomko at redhat.com
Thu Oct 8 12:12:14 UTC 2020


Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 src/libvirt_private.syms |  2 --
 src/util/viralloc.c      | 39 ---------------------------------------
 src/util/viralloc.h      | 33 ---------------------------------
 3 files changed, 74 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 7cf8bea962..152083d220 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1614,8 +1614,6 @@ vir_g_strdup_vprintf;
 
 
 # util/viralloc.h
-virAlloc;
-virAllocN;
 virAllocVar;
 virDeleteElementsN;
 virDispose;
diff --git a/src/util/viralloc.c b/src/util/viralloc.c
index e254416cdf..0360b8a8aa 100644
--- a/src/util/viralloc.c
+++ b/src/util/viralloc.c
@@ -31,45 +31,6 @@
 VIR_LOG_INIT("util.alloc");
 
 
-/**
- * virAlloc:
- * @ptrptr: pointer to pointer for address of allocated memory
- * @size: number of bytes to allocate
- *
- * Allocate  'size' bytes of memory. Return the address of the
- * allocated memory in 'ptrptr'. The newly allocated memory is
- * filled with zeros.
- *
- * Returns zero on success, aborts on OOM
- */
-int virAlloc(void *ptrptr,
-             size_t size)
-{
-    *(void **)ptrptr = g_malloc0(size);
-    return 0;
-}
-
-/**
- * virAllocN:
- * @ptrptr: pointer to pointer for address of allocated memory
- * @size: number of bytes to allocate
- * @count: number of elements to allocate
- *
- * 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.
- *
- * Returns zero on success, aborts on OOM
- */
-int virAllocN(void *ptrptr,
-              size_t size,
-              size_t count)
-{
-    *(void**)ptrptr = g_malloc0_n(count, size);
-    return 0;
-}
-
 /**
  * virReallocN:
  * @ptrptr: pointer to pointer for address of allocated memory
diff --git a/src/util/viralloc.h b/src/util/viralloc.h
index a50cd5d632..1abd94fac4 100644
--- a/src/util/viralloc.h
+++ b/src/util/viralloc.h
@@ -34,10 +34,6 @@
  */
 
 /* Don't call these directly - use the macros below */
-int virAlloc(void *ptrptr, size_t size)
-    G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1);
-int virAllocN(void *ptrptr, size_t size, size_t count)
-    G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1);
 int virReallocN(void *ptrptr, size_t size, size_t count)
     G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1);
 int virExpandN(void *ptrptr, size_t size, size_t *count, size_t add)
@@ -61,35 +57,6 @@ void virDispose(void *ptrptr, size_t count, size_t element_size, size_t *countpt
 void virDisposeString(char **strptr)
     ATTRIBUTE_NONNULL(1);
 
-/**
- * VIR_ALLOC:
- * @ptr: pointer to hold address of allocated memory
- *
- * Allocate sizeof(*ptr) bytes of memory and store
- * the address of allocated memory in 'ptr'. Fill the
- * newly allocated memory with zeros.
- *
- * This macro is safe to use on arguments with side effects.
- *
- * Returns 0 on success, aborts on OOM
- */
-#define VIR_ALLOC(ptr) virAlloc(&(ptr), sizeof(*(ptr)))
-
-/**
- * VIR_ALLOC_N:
- * @ptr: pointer to hold address of allocated memory
- * @count: number of elements to allocate
- *
- * Allocate an array of 'count' elements, each sizeof(*ptr)
- * bytes long and store the address of allocated memory in
- * 'ptr'. Fill the newly allocated memory with zeros.
- *
- * This macro is safe to use on arguments with side effects.
- *
- * Returns 0 on success, aborts on OOM
- */
-#define VIR_ALLOC_N(ptr, count) virAllocN(&(ptr), sizeof(*(ptr)), (count))
-
 /**
  * VIR_REALLOC_N:
  * @ptr: pointer to hold address of allocated memory
-- 
2.26.2




More information about the libvir-list mailing list