/* * mon_getmoremem - get more memory and put it on the free list */ static void mon_getmoremem(void) { mon_entry *chunk; u_int entries; entries = (0 == mon_mem_increments) ? mru_initalloc : mru_incalloc; if (entries) { chunk = eallocarray(entries, sizeof(*chunk)); mru_alloc += entries; for (chunk += entries; entries; entries--) mon_free_entry(--chunk); mon_mem_increments++; } }
static restrict_u * alloc_res6(void) { const size_t cb = V6_SIZEOF_RESTRICT_U; const size_t count = INC_RESLIST6; restrict_u * rl; restrict_u * res; size_t i; UNLINK_HEAD_SLIST(res, resfree6, link); if (res != NULL) return res; rl = eallocarray(count, cb); /* link all but the first onto free list */ res = (void *)((char *)rl + (count - 1) * cb); for (i = count - 1; i > 0; i--) { LINK_SLIST(resfree6, res, link); res = (void *)((char *)res - cb); } INSIST(rl == res); /* allocate the first */ return res; }