mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 01:18:00 +03:00
util: delete VIR_ALLOC and VIR_ALLOC_N
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
19c7b50c94
commit
79cb397b39
@ -1614,8 +1614,6 @@ vir_g_strdup_vprintf;
|
||||
|
||||
|
||||
# util/viralloc.h
|
||||
virAlloc;
|
||||
virAllocN;
|
||||
virAllocVar;
|
||||
virDeleteElementsN;
|
||||
virDispose;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user