Commit 5dd1beec authored by Mark Andrews's avatar Mark Andrews Committed by Evan Hunt
Browse files

mempool didn't work for sizes less than sizeof(void*)

parent dc5b8ec9
Pipeline #3655 passed with stages
in 16 minutes and 20 seconds
......@@ -1841,6 +1841,12 @@ isc__mempool_create(isc_mem_t *mctx0, size_t size, isc_mempool_t **mpctxp) {
mpctx->common.magic = ISCAPI_MPOOL_MAGIC;
mpctx->lock = NULL;
mpctx->mctx = mctx;
/*
* Mempools are stored as a linked list of element.
*/
if (size < sizeof(element)) {
size = sizeof(element);
}
mpctx->size = size;
mpctx->maxalloc = UINT_MAX;
mpctx->allocated = 0;
......
......@@ -137,6 +137,21 @@ ATF_TC_BODY(isc_mem, tc) {
isc_mem_destroy(&localmctx);
result = isc_mem_createx2(0, 0, default_memalloc, default_memfree,
NULL, &localmctx,
ISC_MEMFLAG_FILL | ISC_MEMFLAG_INTERNAL);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
result = isc_mempool_create(localmctx, 2, &mp1);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
tmp = isc_mempool_get(mp1);
ATF_CHECK(tmp != NULL);
isc_mempool_put(mp1, tmp);
isc_mempool_destroy(&mp1);
isc_test_end();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment