MCPcopy Create free account
hub / github.com/F-Stack/f-stack / malloc_socket

Function malloc_socket

dpdk/lib/eal/common/rte_malloc.c:53–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53static void *
54malloc_socket(const char *type, size_t size, unsigned int align,
55 int socket_arg, const bool trace_ena)
56{
57 void *ptr;
58
59 /* return NULL if size is 0 or alignment is not power-of-2 */
60 if (size == 0 || (align && !rte_is_power_of_2(align)))
61 return NULL;
62
63 /* if there are no hugepages and if we are not allocating from an
64 * external heap, use memory from any socket available. checking for
65 * socket being external may return -1 in case of invalid socket, but
66 * that's OK - if there are no hugepages, it doesn't matter.
67 */
68 if (rte_malloc_heap_socket_is_external(socket_arg) != 1 &&
69 !rte_eal_has_hugepages())
70 socket_arg = SOCKET_ID_ANY;
71
72 ptr = malloc_heap_alloc(type, size, socket_arg, 0,
73 align == 0 ? 1 : align, 0, false);
74
75 if (trace_ena)
76 rte_eal_trace_mem_malloc(type, size, align, socket_arg, ptr);
77 return ptr;
78}
79
80/*
81 * Allocate memory on specified heap.

Callers 2

rte_malloc_socketFunction · 0.85
eal_malloc_no_traceFunction · 0.85

Calls 4

rte_eal_has_hugepagesFunction · 0.85
malloc_heap_allocFunction · 0.85
rte_is_power_of_2Function · 0.50

Tested by

no test coverage detected