]> git.droids-corp.org - dpdk.git/commitdiff
mem: more const qualifiers in malloc API
authorThomas Monjalon <thomas.monjalon@6wind.com>
Fri, 12 Jul 2013 10:12:15 +0000 (12:12 +0200)
committerDavid Marchand <david.marchand@6wind.com>
Wed, 26 Feb 2014 10:07:27 +0000 (11:07 +0100)
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>
lib/librte_malloc/malloc_elem.h
lib/librte_malloc/malloc_heap.c
lib/librte_malloc/malloc_heap.h
lib/librte_malloc/rte_malloc.c
lib/librte_malloc/rte_malloc.h

index 247a23b97ff053de66d51db7fb943ef7c944f313..1997109e2383665bfe55009041bbf30e3c44be52 100644 (file)
@@ -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;
index 5bdff27fed88dd199b4c25a16483ba3757578f0e..dec7ab1eb1636f739dfdaf7554522083c85c6fe6 100644 (file)
@@ -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)
index d9a0b4e6e84a31a0abc7c02803d7d858f89e3585..7878840266fafbb226abc926fb0bc00bc695f001 100644 (file)
@@ -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
index 44f19d54d970ef134a84c468fe7ce7dbe6ec882d..53b24da86cd5d7de1f49bde5f1f792a2e37ed48e 100644 (file)
@@ -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)
index 348f8eb0c20065913be604301a4d6d8bf5890fec..dc80d72b68e069603bbd68e5b266459103052780 100644 (file)
@@ -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.