From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anatoly Burakov Subject: [PATCH v3 08/68] eal: make malloc free return resulting malloc element Date: Wed, 4 Apr 2018 00:21:20 +0100 Message-ID: References: Cc: keith.wiles@intel.com, jianfeng.tan@intel.com, andras.kovacs@ericsson.com, laszlo.vadkeri@ericsson.com, benjamin.walker@intel.com, bruce.richardson@intel.com, thomas@monjalon.net, konstantin.ananyev@intel.com, kuralamudhan.ramakrishnan@intel.com, louise.m.daly@intel.com, nelio.laranjeiro@6wind.com, yskoh@mellanox.com, pepperjo@japf.ch, jerin.jacob@caviumnetworks.com, hemant.agrawal@nxp.com, olivier.matz@6wind.com, shreyansh.jain@nxp.com, gowrishankar.m@linux.vnet.ibm.com To: dev@dpdk.org Return-path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id CE7AA1B89B for ; Wed, 4 Apr 2018 01:22:30 +0200 (CEST) In-Reply-To: In-Reply-To: References: List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This will be needed because we need to know how big is the new empty space, to check whether we can free some pages as a result. Signed-off-by: Anatoly Burakov --- Notes: v3: clarified commit message lib/librte_eal/common/malloc_elem.c | 4 ++-- lib/librte_eal/common/malloc_elem.h | 2 +- lib/librte_eal/common/malloc_heap.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/librte_eal/common/malloc_elem.c b/lib/librte_eal/common/malloc_elem.c index 008f5a3..c18f050 100644 --- a/lib/librte_eal/common/malloc_elem.c +++ b/lib/librte_eal/common/malloc_elem.c @@ -379,7 +379,7 @@ malloc_elem_join_adjacent_free(struct malloc_elem *elem) * blocks either immediately before or immediately after newly freed block * are also free, the blocks are merged together. */ -int +struct malloc_elem * malloc_elem_free(struct malloc_elem *elem) { void *ptr; @@ -397,7 +397,7 @@ malloc_elem_free(struct malloc_elem *elem) memset(ptr, 0, data_len); - return 0; + return elem; } /* diff --git a/lib/librte_eal/common/malloc_elem.h b/lib/librte_eal/common/malloc_elem.h index 46e2383..9c1614c 100644 --- a/lib/librte_eal/common/malloc_elem.h +++ b/lib/librte_eal/common/malloc_elem.h @@ -138,7 +138,7 @@ malloc_elem_alloc(struct malloc_elem *elem, size_t size, * blocks either immediately before or immediately after newly freed block * are also free, the blocks are merged together. */ -int +struct malloc_elem * malloc_elem_free(struct malloc_elem *elem); struct malloc_elem * diff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c index 44538d7..a2c2e4c 100644 --- a/lib/librte_eal/common/malloc_heap.c +++ b/lib/librte_eal/common/malloc_heap.c @@ -145,7 +145,7 @@ int malloc_heap_free(struct malloc_elem *elem) { struct malloc_heap *heap; - int ret; + struct malloc_elem *ret; if (!malloc_elem_cookies_ok(elem) || elem->state != ELEM_BUSY) return -1; @@ -159,7 +159,7 @@ malloc_heap_free(struct malloc_elem *elem) rte_spinlock_unlock(&(heap->lock)); - return ret; + return ret != NULL ? 0 : -1; } int -- 2.7.4