-/*
- * initialise a malloc heap object. The heap is locked with a private
- * lock while being initialised. This function should only be called the
- * first time a thread calls malloc - if even then, as heaps are per-socket
- * not per-thread.
- */
-static void
-malloc_heap_init(struct malloc_heap *heap)
-{
- struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-
- rte_eal_mcfg_wait_complete(mcfg);
- while (heap->initialised != INITIALISED) {
- if (rte_atomic32_cmpset(
- (volatile uint32_t*)&heap->initialised,
- NOT_INITIALISED, INITIALISING)) {
-
- heap->free_head = NULL;
- heap->mz_count = 0;
- heap->alloc_count = 0;
- heap->total_size = 0;
- /*
- * Find NUMA socket of heap that is being initialised, so that
- * malloc_heaps[n].numa_socket == n
- */
- heap->numa_socket = heap - mcfg->malloc_heaps;
- rte_spinlock_init(&heap->lock);
- heap->initialised = INITIALISED;
- }
- }
-}
-