diff --git a/lib/isc/include/isc/mem.h b/lib/isc/include/isc/mem.h index fde46200a5..bd72f86549 100644 --- a/lib/isc/include/isc/mem.h +++ b/lib/isc/include/isc/mem.h @@ -364,7 +364,7 @@ isc_mem_renderjson(void *memobj0); #define isc_mempool_create(c, s, mp) \ isc__mempool_create((c), (s), (mp)_ISC_MEM_FILELINE) void -isc__mempool_create(isc_mem_t *mctx, size_t size, +isc__mempool_create(isc_mem_t *restrict mctx, const size_t element_size, isc_mempool_t **mpctxp _ISC_MEM_FLARG); /*%< * Create a memory pool. @@ -385,7 +385,7 @@ isc__mempool_create(isc_mem_t *mctx, size_t size, #define isc_mempool_destroy(mp) isc__mempool_destroy((mp)_ISC_MEM_FILELINE) void -isc__mempool_destroy(isc_mempool_t **mpctxp _ISC_MEM_FLARG); +isc__mempool_destroy(isc_mempool_t **restrict mpctxp _ISC_MEM_FLARG); /*%< * Destroy a memory pool. * @@ -395,7 +395,7 @@ isc__mempool_destroy(isc_mempool_t **mpctxp _ISC_MEM_FLARG); */ void -isc_mempool_setname(isc_mempool_t *mpctx, const char *name); +isc_mempool_setname(isc_mempool_t *restrict mpctx, const char *name); /*%< * Associate a name with a memory pool. At most 15 characters may be *used. @@ -418,38 +418,39 @@ isc_mempool_setname(isc_mempool_t *mpctx, const char *name); */ unsigned int -isc_mempool_getfreemax(isc_mempool_t *mpctx); +isc_mempool_getfreemax(isc_mempool_t *restrict mpctx); /*%< * Returns the maximum allowed size of the free list. */ void -isc_mempool_setfreemax(isc_mempool_t *mpctx, unsigned int limit); +isc_mempool_setfreemax(isc_mempool_t *restrict mpctx, const unsigned int limit); /*%< * Sets the maximum allowed size of the free list. */ unsigned int -isc_mempool_getfreecount(isc_mempool_t *mpctx); +isc_mempool_getfreecount(isc_mempool_t *restrict mpctx); /*%< * Returns current size of the free list. */ unsigned int -isc_mempool_getallocated(isc_mempool_t *mpctx); +isc_mempool_getallocated(isc_mempool_t *restrict mpctx); /*%< * Returns the number of items allocated from this pool. */ unsigned int -isc_mempool_getfillcount(isc_mempool_t *mpctx); +isc_mempool_getfillcount(isc_mempool_t *restrict mpctx); /*%< * Returns the number of items allocated as a block from the parent * memory context when the free list is empty. */ void -isc_mempool_setfillcount(isc_mempool_t *mpctx, unsigned int limit); +isc_mempool_setfillcount(isc_mempool_t *restrict mpctx, + const unsigned int limit); /*%< * Sets the fillcount. * diff --git a/lib/isc/mem.c b/lib/isc/mem.c index 2e7a4126cd..4e92e54c97 100644 --- a/lib/isc/mem.c +++ b/lib/isc/mem.c @@ -1106,9 +1106,10 @@ isc_mem_getname(isc_mem_t *ctx) { */ void -isc__mempool_create(isc_mem_t *mctx, size_t size, - isc_mempool_t **mpctxp FLARG) { - isc_mempool_t *mpctx = NULL; +isc__mempool_create(isc_mem_t *restrict mctx, const size_t element_size, + isc_mempool_t **restrict mpctxp FLARG) { + isc_mempool_t *restrict mpctx = NULL; + size_t size = element_size; REQUIRE(VALID_CONTEXT(mctx)); REQUIRE(size > 0U); @@ -1151,7 +1152,7 @@ isc__mempool_create(isc_mem_t *mctx, size_t size, } void -isc_mempool_setname(isc_mempool_t *mpctx, const char *name) { +isc_mempool_setname(isc_mempool_t *restrict mpctx, const char *name) { REQUIRE(VALID_MEMPOOL(mpctx)); REQUIRE(name != NULL); @@ -1159,10 +1160,10 @@ isc_mempool_setname(isc_mempool_t *mpctx, const char *name) { } void -isc__mempool_destroy(isc_mempool_t **mpctxp FLARG) { - isc_mempool_t *mpctx = NULL; +isc__mempool_destroy(isc_mempool_t **restrict mpctxp FLARG) { + isc_mempool_t *restrict mpctx = NULL; isc_mem_t *mctx = NULL; - element *item = NULL; + element *restrict item = NULL; REQUIRE(mpctxp != NULL); REQUIRE(VALID_MEMPOOL(*mpctxp)); @@ -1216,7 +1217,7 @@ isc__mempool_destroy(isc_mempool_t **mpctxp FLARG) { #if __SANITIZE_ADDRESS__ void * -isc__mempool_get(isc_mempool_t *mpctx FLARG) { +isc__mempool_get(isc_mempool_t *restrict mpctx FLARG) { REQUIRE(VALID_MEMPOOL(mpctx)); mpctx->allocated++; @@ -1226,7 +1227,7 @@ isc__mempool_get(isc_mempool_t *mpctx FLARG) { } void -isc__mempool_put(isc_mempool_t *mpctx, void *mem FLARG) { +isc__mempool_put(isc_mempool_t *restrict mpctx, void *mem FLARG) { REQUIRE(VALID_MEMPOOL(mpctx)); REQUIRE(mem != NULL); @@ -1236,8 +1237,8 @@ isc__mempool_put(isc_mempool_t *mpctx, void *mem FLARG) { #else /* __SANITIZE_ADDRESS__ */ void * -isc__mempool_get(isc_mempool_t *mpctx FLARG) { - element *item = NULL; +isc__mempool_get(isc_mempool_t *restrict mpctx FLARG) { + element *restrict item = NULL; REQUIRE(VALID_MEMPOOL(mpctx)); @@ -1275,8 +1276,8 @@ isc__mempool_get(isc_mempool_t *mpctx FLARG) { /* coverity[+free : arg-1] */ void -isc__mempool_put(isc_mempool_t *mpctx, void *mem FLARG) { - element *item = NULL; +isc__mempool_put(isc_mempool_t *restrict mpctx, void *mem FLARG) { + element *restrict item = NULL; REQUIRE(VALID_MEMPOOL(mpctx)); REQUIRE(mem != NULL); @@ -1315,35 +1316,37 @@ isc__mempool_put(isc_mempool_t *mpctx, void *mem FLARG) { */ void -isc_mempool_setfreemax(isc_mempool_t *mpctx, unsigned int limit) { +isc_mempool_setfreemax(isc_mempool_t *restrict mpctx, + const unsigned int limit) { REQUIRE(VALID_MEMPOOL(mpctx)); mpctx->freemax = limit; } unsigned int -isc_mempool_getfreemax(isc_mempool_t *mpctx) { +isc_mempool_getfreemax(isc_mempool_t *restrict mpctx) { REQUIRE(VALID_MEMPOOL(mpctx)); return (mpctx->freemax); } unsigned int -isc_mempool_getfreecount(isc_mempool_t *mpctx) { +isc_mempool_getfreecount(isc_mempool_t *restrict mpctx) { REQUIRE(VALID_MEMPOOL(mpctx)); return (mpctx->freecount); } unsigned int -isc_mempool_getallocated(isc_mempool_t *mpctx) { +isc_mempool_getallocated(isc_mempool_t *restrict mpctx) { REQUIRE(VALID_MEMPOOL(mpctx)); return (mpctx->allocated); } void -isc_mempool_setfillcount(isc_mempool_t *mpctx, unsigned int limit) { +isc_mempool_setfillcount(isc_mempool_t *restrict mpctx, + unsigned int const limit) { REQUIRE(VALID_MEMPOOL(mpctx)); REQUIRE(limit > 0); @@ -1351,7 +1354,7 @@ isc_mempool_setfillcount(isc_mempool_t *mpctx, unsigned int limit) { } unsigned int -isc_mempool_getfillcount(isc_mempool_t *mpctx) { +isc_mempool_getfillcount(isc_mempool_t *restrict mpctx) { REQUIRE(VALID_MEMPOOL(mpctx)); return (mpctx->fillcount);