| 51 | } |
| 52 | |
| 53 | static void * |
| 54 | malloc_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. |
no test coverage detected