Lines Matching defs:mpctx
1093 isc_mempool_t *restrict mpctx = NULL;
1111 mpctx = isc_mem_get(mctx, sizeof(isc_mempool_t));
1113 *mpctx = (isc_mempool_t){
1122 mpctx, file, line, mctx);
1126 isc_mem_attach(mctx, &mpctx->mctx);
1127 mpctx->magic = MEMPOOL_MAGIC;
1129 *mpctxp = (isc_mempool_t *)mpctx;
1132 ISC_LIST_INITANDAPPEND(mctx->pools, mpctx, link);
1138 isc_mempool_setname(isc_mempool_t *restrict mpctx, const char *name) {
1139 REQUIRE(VALID_MEMPOOL(mpctx));
1142 strlcpy(mpctx->name, name, sizeof(mpctx->name));
1147 isc_mempool_t *restrict mpctx = NULL;
1154 mpctx = *mpctxp;
1157 mctx = mpctx->mctx;
1162 mpctx, file, line, mctx);
1166 if (mpctx->allocated > 0) {
1167 UNEXPECTED_ERROR("mempool %s leaked memory", mpctx->name);
1169 REQUIRE(mpctx->allocated == 0);
1174 while (mpctx->items != NULL) {
1175 INSIST(mpctx->freecount > 0);
1176 mpctx->freecount--;
1178 item = mpctx->items;
1179 mpctx->items = item->next;
1181 mem_putstats(mctx, mpctx->size);
1182 mem_put(mctx, item, mpctx->size, 0);
1189 ISC_LIST_UNLINK(mctx->pools, mpctx, link);
1193 mpctx->magic = 0;
1195 isc_mem_putanddetach(&mpctx->mctx, mpctx, sizeof(isc_mempool_t));
1199 isc__mempool_get(isc_mempool_t *restrict mpctx FLARG) {
1202 REQUIRE(VALID_MEMPOOL(mpctx));
1204 mpctx->allocated++;
1206 if (mpctx->items == NULL) {
1207 isc_mem_t *mctx = mpctx->mctx;
1209 const size_t fillcount = mpctx->fillcount;
1217 item = mem_get(mctx, mpctx->size, 0);
1218 mem_getstats(mctx, mpctx->size);
1219 item->next = mpctx->items;
1220 mpctx->items = item;
1221 mpctx->freecount++;
1225 INSIST(mpctx->items != NULL);
1226 item = mpctx->items;
1228 mpctx->items = item->next;
1230 INSIST(mpctx->freecount > 0);
1231 mpctx->freecount--;
1232 mpctx->gets++;
1234 ADD_TRACE(mpctx->mctx, item, mpctx->size, file, line);
1241 isc__mempool_put(isc_mempool_t *restrict mpctx, void *mem FLARG) {
1244 REQUIRE(VALID_MEMPOOL(mpctx));
1247 isc_mem_t *mctx = mpctx->mctx;
1248 const size_t freecount = mpctx->freecount;
1250 const size_t freemax = mpctx->freemax;
1255 INSIST(mpctx->allocated > 0);
1256 mpctx->allocated--;
1258 DELETE_TRACE(mctx, mem, mpctx->size, file, line);
1264 mem_putstats(mctx, mpctx->size);
1265 mem_put(mctx, mem, mpctx->size, 0);
1273 item->next = mpctx->items;
1274 mpctx->items = item;
1275 mpctx->freecount++;
1283 isc_mempool_setfreemax(isc_mempool_t *restrict mpctx,
1285 REQUIRE(VALID_MEMPOOL(mpctx));
1286 mpctx->freemax = limit;
1290 isc_mempool_getfreemax(isc_mempool_t *restrict mpctx) {
1291 REQUIRE(VALID_MEMPOOL(mpctx));
1293 return mpctx->freemax;
1297 isc_mempool_getfreecount(isc_mempool_t *restrict mpctx) {
1298 REQUIRE(VALID_MEMPOOL(mpctx));
1300 return mpctx->freecount;
1304 isc_mempool_getallocated(isc_mempool_t *restrict mpctx) {
1305 REQUIRE(VALID_MEMPOOL(mpctx));
1307 return mpctx->allocated;
1311 isc_mempool_setfillcount(isc_mempool_t *restrict mpctx,
1313 REQUIRE(VALID_MEMPOOL(mpctx));
1316 mpctx->fillcount = limit;
1320 isc_mempool_getfillcount(isc_mempool_t *restrict mpctx) {
1321 REQUIRE(VALID_MEMPOOL(mpctx));
1323 return mpctx->fillcount;