tor-browser

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

plhashallocops.rst (1231B)


      1 Syntax
      2 ------
      3 
      4 .. code::
      5 
      6   #include <plhash.h>
      7 
      8   typedef struct PLHashAllocOps {
      9     void *(PR_CALLBACK *allocTable)(void *pool, PRSize size);
     10     void (PR_CALLBACK *freeTable)(void *pool, void *item);
     11     PLHashEntry *(PR_CALLBACK *allocEntry)(void *pool, const void *key);
     12     void (PR_CALLBACK *freeEntry)(void *pool, PLHashEntry *he, PRUintn flag);
     13   } PLHashAllocOps;
     14 
     15   #define HT_FREE_VALUE 0 /* just free the entry's value */
     16   #define HT_FREE_ENTRY 1 /* free value and entire entry */
     17 
     18 
     19 Description
     20 -----------
     21 
     22 Users of the hash table functions can provide their own memory
     23 allocation functions. A pair of functions is used to allocate and tree
     24 the table, and another pair of functions is used to allocate and free
     25 the table entries.
     26 
     27 The first argument, pool, for all four functions is a void \* pointer
     28 that is a piece of data for the memory allocator. Typically pool points
     29 to a memory pool used by the memory allocator.
     30 
     31 The ``freeEntry`` function does not need to free the value of the entry.
     32 If flag is ``HT_FREE_ENTRY``, the function frees the entry.
     33 
     34 
     35 Remark
     36 ------
     37 
     38 The ``key`` argument for the ``allocEntry`` function does not seem to be
     39 useful. It is unused in the default ``allocEntry`` function.