Commit 40678c15 authored by Darek Stojaczyk's avatar Darek Stojaczyk
Browse files

env: add spdk_realloc()



It's a copy of spdk_dma_realloc() matching the new
spdk_malloc() naming convention.

Change-Id: I8e1b24aa0bae064392fe0f4ebc08c5723d9a5f1a
Signed-off-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448169


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 5118004b
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -130,6 +130,21 @@ void *spdk_malloc(size_t size, size_t align, uint64_t *phys_addr, int socket_id,
 */
void *spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr, int socket_id, uint32_t flags);

/**
 * Resize a dma/sharable memory buffer with the given new size and alignment.
 * Existing contents are preserved.
 *
 * \param buf Buffer to resize.
 * \param size Size in bytes.
 * \param align Alignment value for the allocated memory. If '0', the allocated
 * buffer is suitably aligned (in the same manner as malloc()). Otherwise, the
 * allocated buffer is aligned to the multiple of align. In this case, it must
 * be a power of two.
 *
 * \return a pointer to the resized memory buffer.
 */
void *spdk_realloc(void *buf, size_t size, size_t align);

/**
 * Free buffer memory that was previously allocated with spdk_malloc() or spdk_zmalloc().
 *
+6 −0
Original line number Diff line number Diff line
@@ -89,6 +89,12 @@ spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr, int socket_id, uint
	return buf;
}

void *
spdk_realloc(void *buf, size_t size, size_t align)
{
	return rte_realloc(buf, size, align);
}

void
spdk_free(void *buf)
{
+9 −0
Original line number Diff line number Diff line
@@ -114,6 +114,15 @@ spdk_dma_malloc(size_t size, size_t align, uint64_t *phys_addr)
	return spdk_malloc(size, align, phys_addr, -1, 1);
}

DEFINE_RETURN_MOCK(spdk_realloc, void *);
void *
spdk_realloc(void *buf, size_t size, size_t align)
{
	HANDLE_RETURN_MOCK(spdk_realloc);

	return realloc(buf, size);
}

DEFINE_RETURN_MOCK(spdk_dma_zmalloc, void *);
void *
spdk_dma_zmalloc(size_t size, size_t align, uint64_t *phys_addr)