summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThomas Monjalon <thomas.monjalon@6wind.com>2013-07-12 12:12:15 +0200
committerThomas Monjalon <thomas.monjalon@6wind.com>2014-01-15 18:08:44 +0100
commit9ad73b32805b90905b19370a8c620713a659949b (patch)
tree42e38082a540b7953808de38ad44db8e93644754 /lib
parentf94c17bf2fd9baa12925c8e98443694a68c0fbf0 (diff)
downloaddpdk-9ad73b32805b90905b19370a8c620713a659949b.zip
dpdk-9ad73b32805b90905b19370a8c620713a659949b.tar.gz
dpdk-9ad73b32805b90905b19370a8c620713a659949b.tar.xz
mem: more const qualifiers in malloc API
Some functions don't modify their parameter which should be marked as const. Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com> Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/librte_malloc/malloc_elem.h6
-rw-r--r--lib/librte_malloc/malloc_heap.c2
-rw-r--r--lib/librte_malloc/malloc_heap.h2
-rw-r--r--lib/librte_malloc/rte_malloc.c4
-rw-r--r--lib/librte_malloc/rte_malloc.h2
5 files changed, 8 insertions, 8 deletions
diff --git a/lib/librte_malloc/malloc_elem.h b/lib/librte_malloc/malloc_elem.h
index f222557..d99e72d 100644
--- a/lib/librte_malloc/malloc_elem.h
+++ b/lib/librte_malloc/malloc_elem.h
@@ -61,7 +61,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
@@ -99,7 +99,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 &&
@@ -116,7 +116,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 7a3e0cb..2d3dfb3 100644
--- a/lib/librte_malloc/malloc_heap.c
+++ b/lib/librte_malloc/malloc_heap.c
@@ -223,7 +223,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 3cfaa36..6973388 100644
--- a/lib/librte_malloc/malloc_heap.h
+++ b/lib/librte_malloc/malloc_heap.h
@@ -52,7 +52,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 fbd7405..ea70eb4 100644
--- a/lib/librte_malloc/rte_malloc.c
+++ b/lib/librte_malloc/rte_malloc.c
@@ -168,9 +168,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 7d11f34..5d38bc2 100644
--- a/lib/librte_malloc/rte_malloc.h
+++ b/lib/librte_malloc/rte_malloc.h
@@ -272,7 +272,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.