Browse Source

Fix mappools

master
Gavin Howard 1 month ago
parent
commit
2a3c610131
Signed by: gavin GPG Key ID: C08038BDF280D33E
  1. 3
      src/map/map.c
  2. 6
      src/map/map.h
  3. 3
      src/mappool/mappool.c

3
src/map/map.c

@ -464,7 +464,8 @@ ymap_create(const float load, const size_t ksize, const size_t esize,
yc_assert(eq || ksize == sizeof(uint64_t), YC_ASSERT_MAP_INVALID_EQ);
yc_assert(load <= 1.0f && load > 0.0f, YC_ASSERT_MAP_LOAD_RANGE);
ymap* m = ycalloc(1, sizeof(ymap) + 3 * ksize + 3 * esize);
ymap* m = ycalloc(1, sizeof(ymap) + YMAP_NSWAPS * ksize +
YMAP_NSWAPS * esize);
if (yerror(!m)) return NULL;
YStatus status = ymap_init(m, load, ksize, esize, hash, eq, kdtor, vdtor);

6
src/map/map.h

@ -219,6 +219,12 @@ extern "C" {
*/
#define YMAP_VSWAP3(kp, ks, es) ((kp) + (ks) + 2 * (es))
/**
* @def YMAP_NSWAPS
* The number of swap areas needed for maps.
*/
#define YMAP_NSWAPS (3)
/**
* This is the actual map struct.
*/

3
src/mappool/mappool.c

@ -95,7 +95,8 @@ ymappool_create(float load, size_t ksize, YHasher hash, YEqual eq,
yc_assert(eq || ksize == sizeof(uint64_t), YC_ASSERT_MAP_INVALID_EQ);
yc_assert(load <= 1.0f && load > 0.0f, YC_ASSERT_MAP_LOAD_RANGE);
size_t size = sizeof(ymappool) + 2 * ksize + 2 * sizeof(ymappool_ref);
size_t size = sizeof(ymappool) + YMAP_NSWAPS * ksize +
YMAP_NSWAPS * sizeof(ymappool_ref);
ymappool* p = (ymappool*) ycalloc(1, size);
if (yerror(!p)) return NULL;

Loading…
Cancel
Save