hashtab.c: Object lookups can be const

The objects passed to the various hashtable removal functions are not
modified, so they can - and should - be `const`.
pull/2188/head
Sean Bright 2 weeks ago committed by github-actions[bot]
parent b21e03d9c8
commit b62d340366

@ -363,11 +363,11 @@ void ast_hashtab_end_traversal(struct ast_hashtab_iter *it);
void *ast_hashtab_next(struct ast_hashtab_iter *it);
/*! \brief Looks up the object, removes the corresponding bucket */
void *ast_hashtab_remove_object_via_lookup(struct ast_hashtab *tab, void *obj);
void *ast_hashtab_remove_object_via_lookup(struct ast_hashtab *tab, const void *obj);
/*! \brief Hash the object and then compare ptrs in bucket list instead of
calling the compare routine, will remove the bucket */
void *ast_hashtab_remove_this_object(struct ast_hashtab *tab, void *obj);
void *ast_hashtab_remove_this_object(struct ast_hashtab *tab, const void *obj);
/* ------------------ */
/* for lock-enabled traversals with ability to remove an object during the traversal*/
@ -379,11 +379,11 @@ struct ast_hashtab_iter *_ast_hashtab_start_write_traversal(struct ast_hashtab *
_ast_hashtab_start_write_traversal(tab, __FILE__, __LINE__, __PRETTY_FUNCTION__)
/*! \brief Looks up the object, removes the corresponding bucket */
void *ast_hashtab_remove_object_via_lookup_nolock(struct ast_hashtab *tab, void *obj);
void *ast_hashtab_remove_object_via_lookup_nolock(struct ast_hashtab *tab, const void *obj);
/*! \brief Hash the object and then compare ptrs in bucket list instead of
calling the compare routine, will remove the bucket */
void *ast_hashtab_remove_this_object_nolock(struct ast_hashtab *tab, void *obj);
void *ast_hashtab_remove_this_object_nolock(struct ast_hashtab *tab, const void *obj);
/* ------------------ */
/* ------------------ */

@ -743,7 +743,7 @@ static void *ast_hashtab_remove_object_internal(struct ast_hashtab *tab, struct
return (void *) obj2; /* inside this code, the obj's are untouchable, but outside, they aren't */
}
void *ast_hashtab_remove_object_via_lookup(struct ast_hashtab *tab, void *obj)
void *ast_hashtab_remove_object_via_lookup(struct ast_hashtab *tab, const void *obj)
{
/* looks up the object; removes the corresponding bucket */
const void *obj2;
@ -762,7 +762,7 @@ void *ast_hashtab_remove_object_via_lookup(struct ast_hashtab *tab, void *obj)
return (void *)obj2;
}
void *ast_hashtab_remove_object_via_lookup_nolock(struct ast_hashtab *tab, void *obj)
void *ast_hashtab_remove_object_via_lookup_nolock(struct ast_hashtab *tab, const void *obj)
{
/* looks up the object; removes the corresponding bucket */
unsigned int h;
@ -786,7 +786,7 @@ void *ast_hashtab_remove_object_via_lookup_nolock(struct ast_hashtab *tab, void
return 0;
}
void *ast_hashtab_remove_this_object(struct ast_hashtab *tab, void *obj)
void *ast_hashtab_remove_this_object(struct ast_hashtab *tab, const void *obj)
{
/* looks up the object by hash and then comparing pts in bucket list instead of
calling the compare routine; removes the bucket -- a slightly cheaper operation */
@ -799,7 +799,7 @@ void *ast_hashtab_remove_this_object(struct ast_hashtab *tab, void *obj)
if (tab->do_locking)
ast_rwlock_wrlock(&tab->lock);
obj2 = ast_hashtab_remove_this_object_nolock(tab,obj);
obj2 = ast_hashtab_remove_this_object_nolock(tab, obj);
if (tab->do_locking)
ast_rwlock_unlock(&tab->lock);
@ -807,7 +807,7 @@ void *ast_hashtab_remove_this_object(struct ast_hashtab *tab, void *obj)
return (void *)obj2;
}
void *ast_hashtab_remove_this_object_nolock(struct ast_hashtab *tab, void *obj)
void *ast_hashtab_remove_this_object_nolock(struct ast_hashtab *tab, const void *obj)
{
/* looks up the object by hash and then comparing pts in bucket list instead of
calling the compare routine; removes the bucket -- a slightly cheaper operation */

Loading…
Cancel
Save