util/bit_array: use spdk_realloc for process sharing
Change-Id: I8fe49388e7bec9306474f27de7c17e767dfa19e8 Signed-off-by: GangCao <gang.cao@intel.com>
This commit is contained in:
parent
84b7670dff
commit
621f96f7aa
@ -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.
|
||||
|
10
lib/env/env.c
vendored
10
lib/env/env.c
vendored
@ -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)
|
||||
{
|
||||
|
@ -32,6 +32,7 @@
|
||||
*/
|
||||
|
||||
#include "spdk/bit_array.h"
|
||||
#include "spdk/env.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
@ -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
|
||||
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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…
Reference in New Issue
Block a user