quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

uint-hash.h (2323B)


      1 #ifndef HEADER_CURL_UINT_HASH_H
      2 #define HEADER_CURL_UINT_HASH_H
      3 /***************************************************************************
      4  *                                  _   _ ____  _
      5  *  Project                     ___| | | |  _ \| |
      6  *                             / __| | | | |_) | |
      7  *                            | (__| |_| |  _ <| |___
      8  *                             \___|\___/|_| \_\_____|
      9  *
     10  * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
     11  *
     12  * This software is licensed as described in the file COPYING, which
     13  * you should have received as part of this distribution. The terms
     14  * are also available at https://curl.se/docs/copyright.html.
     15  *
     16  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
     17  * copies of the Software, and permit persons to whom the Software is
     18  * furnished to do so, under the terms of the COPYING file.
     19  *
     20  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
     21  * KIND, either express or implied.
     22  *
     23  * SPDX-License-Identifier: curl
     24  *
     25  ***************************************************************************/
     26 
     27 #include "curl_setup.h"
     28 
     29 #include <stddef.h>
     30 
     31 #include "llist.h"
     32 
     33 /* A version with unsigned int as key */
     34 typedef void Curl_uint_hash_dtor(unsigned int id, void *value);
     35 struct uint_hash_entry;
     36 
     37 /* Hash for `unsigned int` as key */
     38 struct uint_hash {
     39   struct uint_hash_entry **table;
     40   Curl_uint_hash_dtor *dtor;
     41   unsigned int slots;
     42   unsigned int size;
     43 #ifdef DEBUGBUILD
     44   int init;
     45 #endif
     46 };
     47 
     48 
     49 void Curl_uint_hash_init(struct uint_hash *h,
     50                          unsigned int slots,
     51                          Curl_uint_hash_dtor *dtor);
     52 void Curl_uint_hash_destroy(struct uint_hash *h);
     53 void Curl_uint_hash_clear(struct uint_hash *h);
     54 
     55 bool Curl_uint_hash_set(struct uint_hash *h, unsigned int id, void *value);
     56 bool Curl_uint_hash_remove(struct uint_hash *h, unsigned int id);
     57 void *Curl_uint_hash_get(struct uint_hash *h, unsigned int id);
     58 unsigned int Curl_uint_hash_count(struct uint_hash *h);
     59 
     60 
     61 typedef bool Curl_uint_hash_visit_cb(unsigned int id, void *value,
     62                                      void *user_data);
     63 
     64 void Curl_uint_hash_visit(struct uint_hash *h,
     65                           Curl_uint_hash_visit_cb *cb,
     66                           void *user_data);
     67 
     68 #endif /* HEADER_CURL_UINT_HASH_H */