tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

pl_newhashtable.rst (1797B)


      1 PL_NewHashTable
      2 ===============
      3 
      4 Create a new hash table.
      5 
      6 
      7 Syntax
      8 ------
      9 
     10 .. code::
     11 
     12   #include <plhash.h>
     13 
     14   PLHashTable *PL_NewHashTable(
     15     PRUint32 numBuckets,
     16     PLHashFunction keyHash,
     17     PLHashComparator keyCompare,
     18     PLHashComparator valueCompare,
     19     const PLHashAllocOps *allocOps,
     20     void *allocPriv
     21   );
     22 
     23 
     24 Parameters
     25 ~~~~~~~~~~
     26 
     27 The function has the following parameters:
     28 
     29 ``numBuckets``
     30   The number of buckets in the hash table.
     31 ``keyHash``
     32   Hash function.
     33 ``keyCompare``
     34   Function used to compare keys of entries.
     35 ``valueCompare``
     36   Function used to compare keys of entries.
     37 ``allocOps``
     38   A pointer to a ``PLHashAllocOps`` structure that must exist
     39   throughout the lifetime of the new hash table.
     40 ``allocPriv``
     41   Passed as the first argument (pool).
     42 
     43 
     44 Returns
     45 ~~~~~~~
     46 
     47 The new hash table.
     48 
     49 
     50 Description
     51 -----------
     52 
     53 :ref:`PL_NewHashTable` creates a new hash table. The table has at least 16
     54 buckets. You can pass a value of 0 as ``numBuckets`` to create the
     55 default number of buckets in the new table. The arguments ``keyCompare``
     56 and ``valueCompare`` are functions of type :ref:`PLHashComparator` that the
     57 hash table library functions use to compare the keys and the values of
     58 entries.
     59 
     60 The argument ``allocOps`` points to a ``PLHashAllocOps`` structure that
     61 must exist throughout the lifetime of the new hash table. The hash table
     62 library functions do not make a copy of this structure. When the
     63 allocation functions in ``allocOps`` are invoked, the allocation private
     64 data allocPriv is passed as the first argument (pool). You can specify a
     65 ``NULL`` value for ``allocOps`` to use the default allocation functions.
     66 If ``allocOps`` is ``NULL``, ``allocPriv`` is ignored. Note that the
     67 default ``freeEntry`` function does not free the value of the entry.