* Allocate zero'd memory on specified heap. */
| 106 | * Allocate zero'd memory on specified heap. |
| 107 | */ |
| 108 | void * |
| 109 | rte_zmalloc_socket(const char *type, size_t size, unsigned align, int socket) |
| 110 | { |
| 111 | void *ptr = rte_malloc_socket(type, size, align, socket); |
| 112 | |
| 113 | if (ptr != NULL) { |
| 114 | struct malloc_elem *elem = malloc_elem_from_data(ptr); |
| 115 | |
| 116 | if (elem->dirty) { |
| 117 | memset(ptr, 0, size); |
| 118 | } else { |
| 119 | #ifdef RTE_MALLOC_DEBUG |
| 120 | /* |
| 121 | * If DEBUG is enabled, then freed memory is marked |
| 122 | * with a poison value and set to zero on allocation. |
| 123 | * If DEBUG is disabled then memory is already zeroed. |
| 124 | */ |
| 125 | memset(ptr, 0, size); |
| 126 | #endif |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | rte_eal_trace_mem_zmalloc(type, size, align, socket, ptr); |
| 131 | return ptr; |
| 132 | } |
| 133 | |
| 134 | /* |
| 135 | * Allocate zero'd memory on default heap. |