Commit 1732eeb4 authored by Jim Harris's avatar Jim Harris Committed by Ben Walker
Browse files

env: add spdk_malloc



Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: Ieaca9fdded2231c6d01101b345ac6c9a01608eef
parent cc1146a8
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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.
+11 −4
Original line number Diff line number Diff line
@@ -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) {
		memset(buf, 0, size);
		if (phys_addr) {
	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);
	}
	return buf;
}