Loading include/spdk/env.h +7 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,13 @@ spdk_malloc(size_t size, size_t align, uint64_t *phys_addr); void * spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr); /** * Resize the allocated and pinned memory buffer with the given * new size and alignment. Existing contents are preserved. */ void * spdk_realloc(void *buf, size_t size, size_t align, uint64_t *phys_addr); /** * Free a memory buffer previously allocated with spdk_zmalloc. * This call is never made from the performance path. Loading lib/env/env.c +10 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,16 @@ spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr) return buf; } void * spdk_realloc(void *buf, size_t size, size_t align, uint64_t *phys_addr) { void *new_buf = rte_realloc(buf, size, align); if (new_buf && phys_addr) { *phys_addr = rte_malloc_virt2phy(new_buf); } return new_buf; } void spdk_free(void *buf) { Loading lib/util/bit_array.c +3 −2 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ */ #include "spdk/bit_array.h" #include "spdk/env.h" #include <assert.h> #include <errno.h> Loading Loading @@ -77,7 +78,7 @@ spdk_bit_array_free(struct spdk_bit_array **bap) ba = *bap; *bap = NULL; free(ba); spdk_free(ba); } static inline uint32_t Loading Loading @@ -113,7 +114,7 @@ spdk_bit_array_resize(struct spdk_bit_array **bap, uint32_t num_bits) */ new_size += SPDK_BIT_ARRAY_WORD_BYTES; new_ba = (struct spdk_bit_array *)realloc(*bap, new_size); new_ba = (struct spdk_bit_array *)spdk_realloc(*bap, new_size, 64, NULL); if (!new_ba) { return -ENOMEM; } Loading test/lib/nvme/unit/test_env.c +6 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,12 @@ spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr) return buf; } void * spdk_realloc(void *buf, size_t size, size_t align, uint64_t *phys_addr) { return realloc(buf, size); } void spdk_free(void *buf) { free(buf); Loading test/lib/util/bit_array/bit_array_ut.c +12 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,18 @@ #include "bit_array.c" void * spdk_realloc(void *buf, size_t size, size_t align, uint64_t *phys_addr) { return realloc(buf, size); } void spdk_free(void *buf) { free(buf); } static void test_1bit(void) { Loading Loading
include/spdk/env.h +7 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,13 @@ spdk_malloc(size_t size, size_t align, uint64_t *phys_addr); void * spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr); /** * Resize the allocated and pinned memory buffer with the given * new size and alignment. Existing contents are preserved. */ void * spdk_realloc(void *buf, size_t size, size_t align, uint64_t *phys_addr); /** * Free a memory buffer previously allocated with spdk_zmalloc. * This call is never made from the performance path. Loading
lib/env/env.c +10 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,16 @@ spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr) return buf; } void * spdk_realloc(void *buf, size_t size, size_t align, uint64_t *phys_addr) { void *new_buf = rte_realloc(buf, size, align); if (new_buf && phys_addr) { *phys_addr = rte_malloc_virt2phy(new_buf); } return new_buf; } void spdk_free(void *buf) { Loading
lib/util/bit_array.c +3 −2 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ */ #include "spdk/bit_array.h" #include "spdk/env.h" #include <assert.h> #include <errno.h> Loading Loading @@ -77,7 +78,7 @@ spdk_bit_array_free(struct spdk_bit_array **bap) ba = *bap; *bap = NULL; free(ba); spdk_free(ba); } static inline uint32_t Loading Loading @@ -113,7 +114,7 @@ spdk_bit_array_resize(struct spdk_bit_array **bap, uint32_t num_bits) */ new_size += SPDK_BIT_ARRAY_WORD_BYTES; new_ba = (struct spdk_bit_array *)realloc(*bap, new_size); new_ba = (struct spdk_bit_array *)spdk_realloc(*bap, new_size, 64, NULL); if (!new_ba) { return -ENOMEM; } Loading
test/lib/nvme/unit/test_env.c +6 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,12 @@ spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr) return buf; } void * spdk_realloc(void *buf, size_t size, size_t align, uint64_t *phys_addr) { return realloc(buf, size); } void spdk_free(void *buf) { free(buf); Loading
test/lib/util/bit_array/bit_array_ut.c +12 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,18 @@ #include "bit_array.c" void * spdk_realloc(void *buf, size_t size, size_t align, uint64_t *phys_addr) { return realloc(buf, size); } void spdk_free(void *buf) { free(buf); } static void test_1bit(void) { Loading