env: add spdk_malloc
Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: Ieaca9fdded2231c6d01101b345ac6c9a01608eef
This commit is contained in:
parent
cc1146a8b5
commit
1732eeb4bb
@ -49,6 +49,13 @@ extern "C" {
|
||||
|
||||
struct spdk_pci_device;
|
||||
|
||||
/**
|
||||
* Allocate a pinned, physically contiguous memory buffer with the
|
||||
* given size and alignment.
|
||||
*/
|
||||
void *
|
||||
spdk_malloc(size_t size, size_t align, uint64_t *phys_addr);
|
||||
|
||||
/**
|
||||
* Allocate a pinned, physically contiguous memory buffer with the
|
||||
* given size and alignment. The buffer will be zeroed.
|
||||
|
15
lib/env/env.c
vendored
15
lib/env/env.c
vendored
@ -43,14 +43,21 @@
|
||||
#include <rte_version.h>
|
||||
|
||||
void *
|
||||
spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr)
|
||||
spdk_malloc(size_t size, size_t align, uint64_t *phys_addr)
|
||||
{
|
||||
void *buf = rte_malloc(NULL, size, align);
|
||||
if (buf && phys_addr) {
|
||||
*phys_addr = rte_malloc_virt2phy(buf);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
void *
|
||||
spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr)
|
||||
{
|
||||
void *buf = spdk_malloc(size, align, phys_addr);
|
||||
if (buf) {
|
||||
memset(buf, 0, size);
|
||||
if (phys_addr) {
|
||||
*phys_addr = rte_malloc_virt2phy(buf);
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user