mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
Merge branch '474-mempool-is-broken-if-object-size-is-below-the-alignment-size' into 'master'
Resolve "mempool is broken if object size is below the alignment size" Closes #474 See merge request isc-projects/bind9!635
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user