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