C Collections

chashmap · Section 3

chashmap_create_mp

chashmap_create_mp - create a hash map with custom memory management procedures

C Collections (libccollections, -lccollections)

#include <ccollections/chashmap.h>
 
chmap chashmap_create_mp(size_t initial_bucket_array_size,
                         ccol_data_type key_type, ccol_data_type val_type,
                         ccol_memmgmt_procs *mmgmt_procs, char **err);

Creates a hash map that allocates through the given memory management
procedures. It is a thin inline wrapper over chashmap_create_full(3) that
passes NULL for the custom hashing procedure, so the map uses its own
hashing for the key type.
 
The map picks its implementation from the key and value types, as
chashmap_create_full(3) describes, and an allocator does not change that
choice. Every later allocation of the map goes through these procedures,
the allocations of an iterator over the map included, so the map must be
destroyed while the procedures are valid.

initial_bucket_array_size  Initial number of buckets. A value of 0 is
                           refused and the call fails; a value from 1
                           to 16 gives 16 buckets, and a larger value is
                           rounded up to the next power of two
key_type                   Key type, as a ccol_data_type
val_type                   Value type, as a ccol_data_type
mmgmt_procs                Memory management procedures, or NULL for the
                           default allocator
err                        Optional pointer that receives an error string on
                           failure, or NULL

A newly created map on success.
NULL on failure, with *err set to an error string when err is non-NULL.

A failure is reported, not fatal; the chmap_construct_mp(3) macro layer
calls ccol__fatal_err() instead

chashmap_create(3), chashmap_create_full(3), chmap_construct_mp(3), chmap_init_mp(3), chmap_destroy(3)