diff options
| author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2026-05-01 17:31:27 +0200 |
|---|---|---|
| committer | Sander Vrijders <sander@ouroboros.rocks> | 2026-05-20 08:17:05 +0200 |
| commit | aa3901535516d49c7a881c9c06e3582e1a6f1ada (patch) | |
| tree | c43a881d645060601aa5176a85bd57350fe0cd3f /src/lib/ssm/pool.c | |
| parent | 3be3360349ee823531d6c3e53b188a7e8af2b761 (diff) | |
| download | ouroboros-aa3901535516d49c7a881c9c06e3582e1a6f1ada.tar.gz ouroboros-aa3901535516d49c7a881c9c06e3582e1a6f1ada.zip | |
lib: Fix pool_sharding_test
The test was not correctly taking the correct size class. Moved the
select_size_class to the common header so tests can use it.
Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/lib/ssm/pool.c')
| -rw-r--r-- | src/lib/ssm/pool.c | 27 |
1 files changed, 2 insertions, 25 deletions
diff --git a/src/lib/ssm/pool.c b/src/lib/ssm/pool.c index 6829b217..e9a81688 100644 --- a/src/lib/ssm/pool.c +++ b/src/lib/ssm/pool.c @@ -165,29 +165,6 @@ static __inline__ void list_add_head(struct _ssm_list_head * head, STORE(&head->count, LOAD(&head->count) + 1); } -static __inline__ int select_size_class(struct ssm_pool * pool, - size_t len) -{ - size_t sz; - int i; - - assert(pool != NULL); - - /* Total space needed: header + headspace + data + tailspace */ - sz = sizeof(struct ssm_pk_buff) + SSM_PK_BUFF_HEADSPACE + len - + SSM_PK_BUFF_TAILSPACE; - - for (i = 0; i < SSM_POOL_MAX_CLASSES; i++) { - struct _ssm_size_class * sc; - - sc = &pool->hdr->size_classes[i]; - if (sc->object_size > 0 && sz <= sc->object_size) - return i; - } - - return -1; -} - static __inline__ int find_size_class_for_offset(struct ssm_pool * pool, size_t offset) { @@ -702,7 +679,7 @@ ssize_t ssm_pool_alloc(struct ssm_pool * pool, assert(pool != NULL); assert(spb != NULL); - idx = select_size_class(pool, count); + idx = select_size_class(pool->hdr, count); if (idx >= 0) return alloc_from_sc(pool, idx, count, ptr, spb); @@ -720,7 +697,7 @@ ssize_t ssm_pool_alloc_b(struct ssm_pool * pool, assert(pool != NULL); assert(spb != NULL); - idx = select_size_class(pool, count); + idx = select_size_class(pool->hdr, count); if (idx >= 0) return alloc_from_sc_b(pool, idx, count, ptr, spb, abstime); |
