pl_hashtableadd.rst (1127B)
1 PL_HashTableAdd 2 =============== 3 4 Add a new entry with the specified key and value to the hash table. 5 6 7 Syntax 8 ------ 9 10 .. code:: 11 12 #include <plhash.h> 13 14 PLHashEntry *PL_HashTableAdd( 15 PLHashTable *ht, 16 const void *key, 17 void *value); 18 19 20 Parameters 21 ~~~~~~~~~~ 22 23 The function has the following parameters: 24 25 ``ht`` 26 A pointer to the the hash table to which to add the entry. 27 ``key`` 28 A pointer to the key for the entry to be added. 29 ``value`` 30 A pointer to the value for the entry to be added. 31 32 33 Returns 34 ~~~~~~~ 35 36 A pointer to the new entry. 37 38 39 Description 40 ----------- 41 42 Add a new entry with the specified key and value to the hash table. 43 44 If an entry with the same key already exists in the table, the 45 ``freeEntry`` function is invoked with the ``HT_FREE_VALUE`` flag. You 46 can write your ``freeEntry`` function to free the value of the specified 47 entry if the old value should be freed. The default ``freeEntry`` 48 function does not free the value of the entry. 49 50 :ref:`PL_HashTableAdd` returns ``NULL`` if there is not enough memory to 51 create a new entry. It doubles the number of buckets if the table is 52 overloaded.