diff options
author | Neale Ranns <nranns@cisco.com> | 2020-01-06 21:09:12 +0000 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2020-01-07 12:35:52 +0000 |
commit | c190cf09a36f18b496ab598b6f33839792674e55 (patch) | |
tree | 7215da16fa38b1cb6f14a28e486d18a983641798 /src/vppinfra | |
parent | 22e108d9a94a9ccc0c31c2479740c57cf2a09126 (diff) |
vppinfra: hash [un]set malloc/free takes a const key
Type: refactor
the key is not modified by these functions
Change-Id: I578f054355fca69e8a086bb69013155a01ed759f
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vppinfra')
-rw-r--r-- | src/vppinfra/hash.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/vppinfra/hash.h b/src/vppinfra/hash.h index 59dbf8cde76..e4a65d21e65 100644 --- a/src/vppinfra/hash.h +++ b/src/vppinfra/hash.h @@ -276,7 +276,7 @@ uword hash_bytes (void *v); /* Public inline function allocate and copy key to use in hash for pointer key */ always_inline void -hash_set_mem_alloc (uword ** h, void *key, uword v) +hash_set_mem_alloc (uword ** h, const void *key, uword v) { size_t ksz = hash_header (*h)->user; void *copy = clib_mem_alloc (ksz); @@ -292,14 +292,14 @@ hash_set_mem_alloc (uword ** h, void *key, uword v) /* Public inline function to unset pointer key and then free the key memory */ always_inline void -hash_unset_mem_free (uword ** h, void *key) +hash_unset_mem_free (uword ** h, const void *key) { hash_pair_t *hp = hash_get_pair_mem (*h, key); if (PREDICT_TRUE (hp != NULL)) { - key = uword_to_pointer (hp->key, void *); - hash_unset_mem (*h, key); - clib_mem_free (key); + void *_k = uword_to_pointer (hp->key, void *); + hash_unset_mem (*h, _k); + clib_mem_free (_k); } } |