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

Function malloc_heap_create

dpdk/lib/eal/common/malloc_heap.c:1351–1379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1349}
1350
1351int
1352malloc_heap_create(struct malloc_heap *heap, const char *heap_name)
1353{
1354 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
1355 uint32_t next_socket_id = mcfg->next_socket_id;
1356
1357 /* prevent overflow. did you really create 2 billion heaps??? */
1358 if (next_socket_id > INT32_MAX) {
1359 RTE_LOG(ERR, EAL, "Cannot assign new socket ID's\n");
1360 rte_errno = ENOSPC;
1361 return -1;
1362 }
1363
1364 /* initialize empty heap */
1365 heap->alloc_count = 0;
1366 heap->first = NULL;
1367 heap->last = NULL;
1368 LIST_INIT(heap->free_head);
1369 rte_spinlock_init(&heap->lock);
1370 heap->total_size = 0;
1371 heap->socket_id = next_socket_id;
1372
1373 /* we hold a global mem hotplug writelock, so it's safe to increment */
1374 mcfg->next_socket_id++;
1375
1376 /* set up name */
1377 strlcpy(heap->name, heap_name, RTE_HEAP_NAME_MAX_LEN);
1378 return 0;
1379}
1380
1381int
1382malloc_heap_destroy(struct malloc_heap *heap)

Callers 1

rte_malloc_heap_createFunction · 0.85

Calls 3

rte_spinlock_initFunction · 0.85
strlcpyFunction · 0.50

Tested by

no test coverage detected