From f59ea5f7690c9a01ef6f7f6508084a66c40b1dae Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 26 Apr 2024 19:44:25 +0200 Subject: Merging upstream version 4.2.4. Signed-off-by: Daniel Baumann --- wsutil/wmem/wmem_map.c | 24 ++++++++++++------------ wsutil/wmem/wmem_map.h | 16 ++++++++-------- 2 files changed, 20 insertions(+), 20 deletions(-) (limited to 'wsutil/wmem') diff --git a/wsutil/wmem/wmem_map.c b/wsutil/wmem/wmem_map.c index ea76f45..047b845 100644 --- a/wsutil/wmem/wmem_map.c +++ b/wsutil/wmem/wmem_map.c @@ -231,8 +231,8 @@ wmem_map_contains(wmem_map_t *map, const void *key) { wmem_map_item_t *item; - /* Make sure we have a table */ - if (map->table == NULL) { + /* Make sure we have map and a table */ + if (map == NULL || map->table == NULL) { return false; } @@ -255,8 +255,8 @@ wmem_map_lookup(wmem_map_t *map, const void *key) { wmem_map_item_t *item; - /* Make sure we have a table */ - if (map->table == NULL) { + /* Make sure we have map and a table */ + if (map == NULL || map->table == NULL) { return NULL; } @@ -279,8 +279,8 @@ wmem_map_lookup_extended(wmem_map_t *map, const void *key, const void **orig_key { wmem_map_item_t *item; - /* Make sure we have a table */ - if (map->table == NULL) { + /* Make sure we have map and a table */ + if (map == NULL || map->table == NULL) { return false; } @@ -310,8 +310,8 @@ wmem_map_remove(wmem_map_t *map, const void *key) wmem_map_item_t **item, *tmp; void *value; - /* Make sure we have a table */ - if (map->table == NULL) { + /* Make sure we have map and a table */ + if (map == NULL || map->table == NULL) { return NULL; } @@ -341,8 +341,8 @@ wmem_map_steal(wmem_map_t *map, const void *key) { wmem_map_item_t **item, *tmp; - /* Make sure we have a table */ - if (map->table == NULL) { + /* Make sure we have map and a table */ + if (map == NULL || map->table == NULL) { return false; } @@ -395,7 +395,7 @@ wmem_map_foreach(wmem_map_t *map, GHFunc foreach_func, void * user_data) unsigned i; /* Make sure we have a table */ - if (map->table == NULL) { + if (map == NULL || map->table == NULL) { return; } @@ -415,7 +415,7 @@ wmem_map_foreach_remove(wmem_map_t *map, GHRFunc foreach_func, void * user_data) unsigned i, deleted = 0; /* Make sure we have a table */ - if (map->table == NULL) { + if (map == NULL || map->table == NULL) { return 0; } diff --git a/wsutil/wmem/wmem_map.h b/wsutil/wmem/wmem_map.h index a6886dd..cb296fb 100644 --- a/wsutil/wmem/wmem_map.h +++ b/wsutil/wmem/wmem_map.h @@ -79,7 +79,7 @@ G_GNUC_MALLOC; /** Inserts a value into the map. * - * @param map The map to insert into. + * @param map The map to insert into. Must not be NULL. * @param key The key to insert by. * @param value The value to insert. * @return The previous value stored at this key if any, or NULL. @@ -90,7 +90,7 @@ wmem_map_insert(wmem_map_t *map, const void *key, void *value); /** Check if a value is in the map. * - * @param map The map to search in. + * @param map The map to search in. May be NULL. * @param key The key to lookup. * @return true if the key is in the map, otherwise false. */ @@ -100,7 +100,7 @@ wmem_map_contains(wmem_map_t *map, const void *key); /** Lookup a value in the map. * - * @param map The map to search in. + * @param map The map to search in. May be NULL. * @param key The key to lookup. * @return The value stored at the key if any, or NULL. */ @@ -111,7 +111,7 @@ wmem_map_lookup(wmem_map_t *map, const void *key); /** Lookup a value in the map, returning the key, value, and a boolean which * is true if the key is found. * - * @param map The map to search in. + * @param map The map to search in. May be NULL. * @param key The key to lookup. * @param orig_key (optional) The key that was determined to be a match, if any. * @param value (optional) The value stored at the key, if any. @@ -124,7 +124,7 @@ wmem_map_lookup_extended(wmem_map_t *map, const void *key, const void **orig_key /** Remove a value from the map. If no value is stored at that key, nothing * happens. * - * @param map The map to remove from. + * @param map The map to remove from. May be NULL. * @param key The key of the value to remove. * @return The (removed) value stored at the key if any, or NULL. */ @@ -135,7 +135,7 @@ wmem_map_remove(wmem_map_t *map, const void *key); /** Remove a key and value from the map but does not destroy (free) them. If no * value is stored at that key, nothing happens. * - * @param map The map to remove from. + * @param map The map to remove from. May be NULL. * @param key The key of the value to remove. * @return true if key is found false if not. */ @@ -157,7 +157,7 @@ wmem_map_get_keys(wmem_allocator_t *list_allocator, wmem_map_t *map); * of the calls is unpredictable, since it is based on the internal * storage of data. * - * @param map The map to use + * @param map The map to use. May be NULL. * @param foreach_func the function to call for each key/value pair * @param user_data user data to pass to the function */ @@ -170,7 +170,7 @@ wmem_map_foreach(wmem_map_t *map, GHFunc foreach_func, void * user_data); * the map. The order of the calls is unpredictable, since it is * based on the internal storage of data. * - * @param map The map to use + * @param map The map to use. May be NULL. * @param foreach_func the function to call for each key/value pair * @param user_data user data to pass to the function * @return The number of items removed -- cgit v1.2.3