Function hashmap_element_space

Function Documentation

static inline size_t hashmap_element_space(size_t n_buckets, size_t bucket_size, size_t elt_size)

Calculate the # of bytes that the hashmap will require if RCSW_NOALLOC_DATA is passed to manage a specified # of elements of a specified size.

We compute the # max elements so that you don’t have to worry about the # buckets not being an even multiple of the max # elements, and allocating too little space because of rounding errors.

Parameters:
  • n_buckets – The # buckets in the hashmap.

  • bucket_size – The size of each bucket in the hashmap.

  • elt_size – Size of elements in bytes.

Returns:

The total # of bytes the application would need to allocate.