From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f44.google.com (mail-wg0-f44.google.com [74.125.82.44]) by dpdk.org (Postfix) with ESMTP id 4B06C5942 for ; Fri, 26 Jul 2013 16:06:21 +0200 (CEST) Received: by mail-wg0-f44.google.com with SMTP id l18so2865081wgh.35 for ; Fri, 26 Jul 2013 07:06:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:x-mailer:x-gm-message-state; bh=exQiy+RkKLDSIUX6UFn+E9uEx1zfcZqlUnmuu99t8TA=; b=RGZqfwdr/FA/zaiKc7XMBckvfw0QVM2vCbkjDpRDxa2YTOuBjxAPOrAt3m8Wo0ukuV BpCOqMV4oEj968AN+FZfKzkBW0XyIMDkbUl3Cw06YvVCDqOSyQYTjHziQaRmB0DeKG3V Tacc5Zp2R6ixxieOlmHdAZeA7mADBgHeyvST5swLMhPb7M3uPTSaiZVU7rDwu0B6KBzA zVVRyGabeuuWSiq+plpsrfi0BLGZrg4OiOTlnCmRK1m63Oh7iTcX1VYnLJXlF1mKpHQx 2i4RjLrNipwimdcEeIDlk7OpmlxUb4Mxqwsc985rKqix8Aj079FZJR96IdHDtg2jng+I d0vg== X-Received: by 10.180.102.36 with SMTP id fl4mr5793973wib.45.1374847604138; Fri, 26 Jul 2013 07:06:44 -0700 (PDT) Received: from 6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id b20sm5023834wiw.4.2013.07.26.07.06.41 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 26 Jul 2013 07:06:43 -0700 (PDT) Received: by 6wind.com (sSMTP sendmail emulation); Fri, 26 Jul 2013 16:06:40 +0200 From: Thomas Monjalon To: dev@dpdk.org Date: Fri, 26 Jul 2013 16:06:40 +0200 Message-Id: <1374847600-25295-1-git-send-email-thomas.monjalon@6wind.com> X-Mailer: git-send-email 1.7.10.4 X-Gm-Message-State: ALoCoQlmsgLagNom4PCokA217eKiRXX+mQD7by6/1PJ4fptCmXVP1xRiqNloFk67Jq3OhHD3wg9k Subject: [dpdk-dev] [PATCH] mem: more const qualifiers in malloc API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Jul 2013 14:06:21 -0000 Some functions don't modify their parameter which should be marked as const. Signed-off-by: Thomas Monjalon --- lib/librte_malloc/malloc_elem.h | 6 +++--- lib/librte_malloc/malloc_heap.c | 2 +- lib/librte_malloc/malloc_heap.h | 2 +- lib/librte_malloc/rte_malloc.c | 4 ++-- lib/librte_malloc/rte_malloc.h | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/librte_malloc/malloc_elem.h b/lib/librte_malloc/malloc_elem.h index 8a75e0c..fadf0a5 100644 --- a/lib/librte_malloc/malloc_elem.h +++ b/lib/librte_malloc/malloc_elem.h @@ -62,7 +62,7 @@ static const unsigned MALLOC_ELEM_TRAILER_LEN = 0; /* dummy function - just check if pointer is non-null */ static inline int -malloc_elem_cookies_ok(struct malloc_elem *elem){ return elem != NULL; } +malloc_elem_cookies_ok(const struct malloc_elem *elem){ return elem != NULL; } /* dummy function - no header if malloc_debug is not enabled */ static inline void @@ -100,7 +100,7 @@ set_trailer(struct malloc_elem *elem) /* check that the header and trailer cookies are set correctly */ static inline int -malloc_elem_cookies_ok(struct malloc_elem *elem) +malloc_elem_cookies_ok(const struct malloc_elem *elem) { return (elem != NULL && MALLOC_ELEM_HEADER(elem) == MALLOC_HEADER_COOKIE && @@ -117,7 +117,7 @@ static const unsigned MALLOC_ELEM_HEADER_LEN = sizeof(struct malloc_elem); * the actual malloc_elem header for that block. */ static inline struct malloc_elem * -malloc_elem_from_data(void *data) +malloc_elem_from_data(const void *data) { if (data == NULL) return NULL; diff --git a/lib/librte_malloc/malloc_heap.c b/lib/librte_malloc/malloc_heap.c index b6d83a4..54b6b0c 100644 --- a/lib/librte_malloc/malloc_heap.c +++ b/lib/librte_malloc/malloc_heap.c @@ -201,7 +201,7 @@ malloc_heap_alloc(struct malloc_heap *heap, * Function to retrieve data for heap on given socket */ int -malloc_heap_get_stats(struct malloc_heap *heap, +malloc_heap_get_stats(const struct malloc_heap *heap, struct rte_malloc_socket_stats *socket_stats) { if (!heap->initialised) diff --git a/lib/librte_malloc/malloc_heap.h b/lib/librte_malloc/malloc_heap.h index e4a5063..e3eb906 100644 --- a/lib/librte_malloc/malloc_heap.h +++ b/lib/librte_malloc/malloc_heap.h @@ -53,7 +53,7 @@ malloc_heap_alloc(struct malloc_heap *heap, const char *type, size_t size, unsigned align); int -malloc_heap_get_stats(struct malloc_heap *heap, +malloc_heap_get_stats(const struct malloc_heap *heap, struct rte_malloc_socket_stats *socket_stats); int diff --git a/lib/librte_malloc/rte_malloc.c b/lib/librte_malloc/rte_malloc.c index 03db51f..e16ba9c 100644 --- a/lib/librte_malloc/rte_malloc.c +++ b/lib/librte_malloc/rte_malloc.c @@ -169,9 +169,9 @@ rte_realloc(void *ptr, size_t size, unsigned align) } int -rte_malloc_validate(void *ptr, size_t *size) +rte_malloc_validate(const void *ptr, size_t *size) { - struct malloc_elem *elem = malloc_elem_from_data(ptr); + const struct malloc_elem *elem = malloc_elem_from_data(ptr); if (!malloc_elem_cookies_ok(elem)) return -1; if (size != NULL) diff --git a/lib/librte_malloc/rte_malloc.h b/lib/librte_malloc/rte_malloc.h index 64ffaf0..acf2ae0 100644 --- a/lib/librte_malloc/rte_malloc.h +++ b/lib/librte_malloc/rte_malloc.h @@ -273,7 +273,7 @@ rte_free(void *ptr); * 0 on success */ int -rte_malloc_validate(void *ptr, size_t *size); +rte_malloc_validate(const void *ptr, size_t *size); /** * Get heap statistics for the specified heap. -- 1.7.10.4