Ignore:
Timestamp:
2019-02-25T14:42:38Z (5 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a4e78743
Parents:
ee8d4d6
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-25 14:42:38)
git-committer:
GitHub <noreply@…> (2019-02-25 14:42:38)
Message:

Indicate and enforce constness of hash table key in certain functions (#158)

The assumption here is that modifying key in the hash/equal functions in something completely unexpected, and not something you would ever want to do intentionally, so it makes sense to disallow it entirely to get that extra level of checking.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/adt/hash_table.h

    ree8d4d6 r5e801dc  
    5353
    5454        /** Returns the hash of the key. */
    55         size_t (*key_hash)(void *key);
     55        size_t (*key_hash)(const void *key);
    5656
    5757        /** True if the items are equal (have the same lookup keys). */
     
    5959
    6060        /** Returns true if the key is equal to the item's lookup key. */
    61         bool (*key_equal)(void *key, const ht_link_t *item);
     61        bool (*key_equal)(const void *key, const ht_link_t *item);
    6262
    6363        /** Hash table item removal callback.
     
    9494extern void hash_table_insert(hash_table_t *, ht_link_t *);
    9595extern bool hash_table_insert_unique(hash_table_t *, ht_link_t *);
    96 extern ht_link_t *hash_table_find(const hash_table_t *, void *);
     96extern ht_link_t *hash_table_find(const hash_table_t *, const void *);
    9797extern ht_link_t *hash_table_find_next(const hash_table_t *, ht_link_t *,
    9898    ht_link_t *);
    99 extern size_t hash_table_remove(hash_table_t *, void *);
     99extern size_t hash_table_remove(hash_table_t *, const void *);
    100100extern void hash_table_remove_item(hash_table_t *, ht_link_t *);
    101101extern void hash_table_apply(hash_table_t *, bool (*)(ht_link_t *, void *),
Note: See TracChangeset for help on using the changeset viewer.