| 1349 | } |
| 1350 | |
| 1351 | int |
| 1352 | malloc_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 | |
| 1381 | int |
| 1382 | malloc_heap_destroy(struct malloc_heap *heap) |
no test coverage detected