Ignore:
Timestamp:
2018-02-28T17:52:03Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3061bc1
Parents:
df6ded8
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:26:03)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:52:03)
Message:

style: Remove trailing whitespace on non-empty lines, in certain file types.

Command used: tools/srepl '\([^[:space:]]\)\s\+$' '\1' -- *.c *.h *.py *.sh *.s *.S *.ag

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/adt/hash_table.c

    rdf6ded8 r1b20da0  
    22 * Copyright (c) 2008 Jakub Jermar
    33 * Copyright (c) 2012 Adam Hraska
    4  * 
     4 *
    55 * All rights reserved.
    66 *
     
    3737/*
    3838 * This is an implementation of a generic resizable chained hash table.
    39  * 
    40  * The table grows to 2*n+1 buckets each time, starting at n == 89, 
     39 *
     40 * The table grows to 2*n+1 buckets each time, starting at n == 89,
    4141 * per Thomas Wang's recommendation:
    4242 * http://www.concentric.net/~Ttwang/tech/hashsize.htm
    43  * 
     43 *
    4444 * This policy produces prime table sizes for the first five resizes
    45  * and generally produces table sizes which are either prime or 
     45 * and generally produces table sizes which are either prime or
    4646 * have fairly large (prime/odd) divisors. Having a prime table size
    4747 * mitigates the use of suboptimal hash functions and distributes
     
    7979 * @param h        Hash table structure. Will be initialized by this call.
    8080 * @param init_size Initial desired number of hash table buckets. Pass zero
    81  *                 if you want the default initial size. 
     81 *                 if you want the default initial size.
    8282 * @param max_load The table is resized when the average load per bucket
    8383 *                 exceeds this number. Pass zero if you want the default.
     
    8686 *                 upon removal. equal() is optional if and only if
    8787 *                 hash_table_insert_unique() will never be invoked.
    88  *                 All other operations are mandatory. 
     88 *                 All other operations are mandatory.
    8989 *
    9090 * @return True on success
     
    210210 * @param h    Hash table.
    211211 * @param item Item to be inserted into the hash table.
    212  * 
    213  * @return False if such an item had already been inserted. 
     212 *
     213 * @return False if such an item had already been inserted.
    214214 * @return True if the inserted item was the only item with such a lookup key.
    215215 */
     
    225225        /* Check for duplicates. */
    226226        list_foreach(h->bucket[idx], link, ht_link_t, cur_link) {
    227                 /* 
    228                  * We could filter out items using their hashes first, but 
     227                /*
     228                 * We could filter out items using their hashes first, but
    229229                 * calling equal() might very well be just as fast.
    230230                 */
     
    255255
    256256        list_foreach(h->bucket[idx], link, ht_link_t, cur_link) {
    257                 /* 
    258                  * Is this is the item we are looking for? We could have first 
    259                  * checked if the hashes match but op->key_equal() may very well be 
     257                /*
     258                 * Is this is the item we are looking for? We could have first
     259                 * checked if the hashes match but op->key_equal() may very well be
    260260                 * just as fast as op->hash().
    261261                 */
     
    278278                assert(cur);
    279279                ht_link_t *cur_link = member_to_inst(cur, ht_link_t, link);
    280                 /* 
    281                  * Is this is the item we are looking for? We could have first 
    282                  * checked if the hashes match but op->equal() may very well be 
     280                /*
     281                 * Is this is the item we are looking for? We could have first
     282                 * checked if the hashes match but op->equal() may very well be
    283283                 * just as fast as op->hash().
    284284                 */
     
    299299 *             the hash table.
    300300 * @param keys Number of keys in the 'key' array.
    301  * 
     301 *
    302302 * @return Returns the number of removed items.
    303303 */
     
    343343 *
    344344 * @param h   Hash table.
    345  * @param f   Function to be applied. Return false if no more items 
     345 * @param f   Function to be applied. Return false if no more items
    346346 *            should be visited. The functor may only delete the supplied
    347  *            item. It must not delete the successor of the item passed 
     347 *            item. It must not delete the successor of the item passed
    348348 *            in the first argument.
    349349 * @param arg Argument to be passed to the function.
    350350 */
    351351void hash_table_apply(hash_table_t *h, bool (*f)(ht_link_t *, void *), void *arg)
    352 {       
     352{
    353353        assert(f);
    354354        assert(h && h->bucket);
     
    362362                list_foreach_safe(h->bucket[idx], cur, next) {
    363363                        ht_link_t *cur_link = member_to_inst(cur, ht_link_t, link);
    364                         /* 
    365                          * The next pointer had already been saved. f() may safely 
     364                        /*
     365                         * The next pointer had already been saved. f() may safely
    366366                         * delete cur (but not next!).
    367367                         */
     
    410410{
    411411        if (h->item_cnt <= h->full_item_cnt / 4 && HT_MIN_BUCKETS < h->bucket_cnt) {
    412                 /* 
    413                  * Keep the bucket_cnt odd (possibly also prime). 
     412                /*
     413                 * Keep the bucket_cnt odd (possibly also prime).
    414414                 * Shrink from 2n + 1 to n. Integer division discards the +1.
    415415                 */
     
    431431
    432432/** Allocates and rehashes items to a new table. Frees the old table. */
    433 static void resize(hash_table_t *h, size_t new_bucket_cnt) 
     433static void resize(hash_table_t *h, size_t new_bucket_cnt)
    434434{
    435435        assert(h && h->bucket);
Note: See TracChangeset for help on using the changeset viewer.