| 626 | } |
| 627 | |
| 628 | int |
| 629 | rte_malloc_heap_destroy(const char *heap_name) |
| 630 | { |
| 631 | struct malloc_heap *heap = NULL; |
| 632 | int ret; |
| 633 | |
| 634 | if (heap_name == NULL || |
| 635 | strnlen(heap_name, RTE_HEAP_NAME_MAX_LEN) == 0 || |
| 636 | strnlen(heap_name, RTE_HEAP_NAME_MAX_LEN) == |
| 637 | RTE_HEAP_NAME_MAX_LEN) { |
| 638 | rte_errno = EINVAL; |
| 639 | return -1; |
| 640 | } |
| 641 | rte_mcfg_mem_write_lock(); |
| 642 | |
| 643 | /* start from non-socket heaps */ |
| 644 | heap = find_named_heap(heap_name); |
| 645 | if (heap == NULL) { |
| 646 | RTE_LOG(ERR, EAL, "Heap %s not found\n", heap_name); |
| 647 | rte_errno = ENOENT; |
| 648 | ret = -1; |
| 649 | goto unlock; |
| 650 | } |
| 651 | /* we shouldn't be able to destroy internal heaps */ |
| 652 | if (heap->socket_id < RTE_MAX_NUMA_NODES) { |
| 653 | rte_errno = EPERM; |
| 654 | ret = -1; |
| 655 | goto unlock; |
| 656 | } |
| 657 | /* sanity checks done, now we can destroy the heap */ |
| 658 | rte_spinlock_lock(&heap->lock); |
| 659 | ret = malloc_heap_destroy(heap); |
| 660 | rte_spinlock_unlock(&heap->lock); |
| 661 | unlock: |
| 662 | rte_mcfg_mem_write_unlock(); |
| 663 | |
| 664 | return ret; |
| 665 | } |