Lines Matching defs:mopts

84 #define MALLOC_MOVE_COND(sz)	((sz) - mopts.malloc_guard < 		\
88 ((sz) - mopts.malloc_guard)) & \
251 #define DO_STATS mopts.malloc_stats
261 struct malloc_readonly mopts;
265 #define mopts malloc_readonly.mopts
351 if (mopts.malloc_pool[1] == NULL || !mopts.malloc_pool[1]->malloc_mt)
352 return mopts.malloc_pool[1];
354 return mopts.malloc_pool[1 + TIB_GET()->tib_tid %
355 (mopts.malloc_mutexes - 1)];
372 if (DO_STATS && mopts.malloc_verbose)
405 mopts.malloc_mutexes <<= 1;
406 if (mopts.malloc_mutexes > _MALLOC_MUTEXES)
407 mopts.malloc_mutexes = _MALLOC_MUTEXES;
410 mopts.malloc_mutexes >>= 1;
411 if (mopts.malloc_mutexes < 2)
412 mopts.malloc_mutexes = 2;
415 mopts.def_maxcache <<= 1;
416 if (mopts.def_maxcache > MALLOC_MAXCACHE)
417 mopts.def_maxcache = MALLOC_MAXCACHE;
420 mopts.def_maxcache >>= 1;
423 mopts.chunk_canaries = 0;
426 mopts.chunk_canaries = 1;
430 mopts.malloc_stats = 0;
434 mopts.malloc_stats = 1;
437 mopts.malloc_stats = 2;
440 mopts.malloc_stats = 3;
443 mopts.malloc_stats = 4;
447 mopts.malloc_freecheck = 0;
448 mopts.malloc_freeunmap = 0;
451 mopts.malloc_freecheck = 1;
452 mopts.malloc_freeunmap = 1;
455 mopts.malloc_guard = 0;
458 mopts.malloc_guard = MALLOC_PAGESIZE;
461 if (mopts.def_malloc_junk > 0)
462 mopts.def_malloc_junk--;
465 if (mopts.def_malloc_junk < 2)
466 mopts.def_malloc_junk++;
469 mopts.malloc_realloc = 0;
472 mopts.malloc_realloc = 1;
475 mopts.malloc_freeunmap = 0;
478 mopts.malloc_freeunmap = 1;
482 mopts.malloc_verbose = 0;
485 mopts.malloc_verbose = 1;
489 mopts.malloc_xmalloc = 0;
492 mopts.malloc_xmalloc = 1;
512 mopts.malloc_mutexes = 8;
513 mopts.def_malloc_junk = 1;
514 mopts.def_maxcache = MALLOC_DEFAULT_CACHE;
543 mopts.def_maxcache = 0;
548 mopts.def_maxcache = MALLOC_DEFAULT_CACHE;
564 while ((mopts.malloc_canary = arc4random()) == 0)
566 mopts.junk_loc = arc4random();
567 if (mopts.chunk_canaries)
569 mopts.chunk_canaries = arc4random();
570 } while ((u_char)mopts.chunk_canaries == 0 ||
571 (u_char)mopts.chunk_canaries == SOME_FREEJUNK);
588 d->malloc_junk = mopts.def_malloc_junk;
592 d->canary1 = mopts.malloc_canary ^ (u_int32_t)(uintptr_t)d;
684 if (mopts.malloc_canary != (d->canary1 ^ (u_int32_t)(uintptr_t)d) ||
752 for (i = mopts.junk_loc % step; i < sz; i += step)
773 for (i = mopts.junk_loc % step; i < sz; i += step) {
829 if (!mopts.malloc_freeunmap)
838 if (mopts.malloc_freeunmap) {
862 if (!fresh && !mopts.malloc_freeunmap)
874 if (mopts.malloc_freeunmap)
890 if (mopts.malloc_canary != (d->canary1 ^ (u_int32_t)(uintptr_t)d) ||
911 if (!mopts.malloc_freeunmap)
913 if (mopts.malloc_freeunmap)
917 else if (mopts.malloc_freeunmap)
939 if (!fresh && !mopts.malloc_freeunmap)
941 if (mopts.malloc_freeunmap)
945 else if (mopts.malloc_freeunmap)
960 if (mopts.malloc_freeunmap)
1012 if (mopts.chunk_canaries && bucket > 0)
1148 if (mopts.def_maxcache != 0)
1160 memset(ptr + sz, mopts.chunk_canaries, check_sz);
1174 if (mopts.malloc_canary != (d->canary1 ^ (u_int32_t)(uintptr_t)d) ||
1227 if (mopts.chunk_canaries && size > 0)
1238 if (mopts.chunk_canaries)
1256 if (*p != (u_char)mopts.chunk_canaries && *p != SOME_JUNK) {
1317 if (info->bucket == 0 && !mopts.malloc_freeunmap)
1339 if (sz >= SIZE_MAX - mopts.malloc_guard - MALLOC_PAGESIZE) {
1343 sz += mopts.malloc_guard;
1359 if (mopts.malloc_guard) {
1360 if (mprotect((char *)p + psz - mopts.malloc_guard,
1361 mopts.malloc_guard, PROT_NONE))
1363 STATS_ADD(pool->malloc_guarded, mopts.malloc_guard);
1369 memset(p, SOME_JUNK, psz - mopts.malloc_guard);
1374 memset(p, 0, sz - mopts.malloc_guard);
1379 mopts.malloc_guard, SOME_JUNK,
1383 psz - mopts.malloc_guard);
1384 } else if (mopts.chunk_canaries)
1385 fill_canary(p, sz - mopts.malloc_guard,
1386 psz - mopts.malloc_guard);
1425 if (!from_rthreads && mopts.malloc_pool[1]) {
1429 if (!mopts.malloc_canary) {
1439 sz = mopts.malloc_mutexes * sizeof(*d);
1453 for (i = 0; i < mopts.malloc_mutexes; i++)
1454 mopts.malloc_pool[i] = &d[i];
1455 mopts.internal_funcs = 1;
1468 nmutexes = from_rthreads ? mopts.malloc_mutexes : 2;
1470 d = mopts.malloc_pool[i];
1484 d->malloc_junk = mopts.def_malloc_junk;
1485 d->bigcache_size = mopts.def_maxcache;
1488 mopts.def_maxcache >> (j / 8);
1531 if (r == NULL && mopts.malloc_xmalloc) \
1558 PROLOGUE(mopts.malloc_pool[0], "malloc_conceal")
1576 nmutexes = mopts.malloc_pool[1]->malloc_mt ?
1577 mopts.malloc_mutexes : 2;
1583 pool = mopts.malloc_pool[j];
1616 argsz -= mopts.malloc_guard;
1621 if (mopts.chunk_canaries && sz > 0) {
1637 } else if (sz - mopts.malloc_guard < argsz) {
1639 sz - mopts.malloc_guard, argsz);
1646 if (mopts.chunk_canaries)
1648 sz - mopts.malloc_guard,
1649 PAGEROUND(sz - mopts.malloc_guard));
1656 if (mopts.malloc_guard) {
1657 if (sz < mopts.malloc_guard)
1659 if (!mopts.malloc_freeunmap) {
1661 mopts.malloc_guard, mopts.malloc_guard,
1665 STATS_SUB(pool->malloc_guarded, mopts.malloc_guard);
1677 find_chunknum(pool, info, p, mopts.chunk_canaries);
1679 if (mopts.malloc_freecheck) {
1714 if (!mopts.malloc_freecheck) {
1771 if (!mopts.internal_funcs) {
1807 if (newsz >= SIZE_MAX - mopts.malloc_guard - MALLOC_PAGESIZE) {
1816 if (DO_STATS || mopts.chunk_canaries) {
1824 if (oldsz < mopts.malloc_guard)
1826 oldsz -= mopts.malloc_guard;
1831 gnewsz += mopts.malloc_guard;
1833 forced = mopts.malloc_realloc || pool->mmap_flag;
1841 roldsz - rnewsz < mopts.def_maxcache * MALLOC_PAGESIZE &&
1842 !mopts.malloc_guard) {
1850 if (!mopts.malloc_guard) {
1867 if (mopts.chunk_canaries)
1878 if (mopts.malloc_guard) {
1880 mopts.malloc_guard, mopts.malloc_guard,
1893 } else if (mopts.chunk_canaries)
1912 rnewsz - mopts.malloc_guard -
1914 if (mopts.chunk_canaries)
1928 if (mopts.chunk_canaries) {
1996 if (mopts.malloc_xmalloc)
2016 PROLOGUE(mopts.malloc_pool[0], "calloc_conceal")
2022 if (mopts.malloc_xmalloc)
2055 if (mopts.chunk_canaries && sz > 0) {
2069 if (sz - mopts.malloc_guard < oldsize)
2071 sz - mopts.malloc_guard, oldsize);
2072 if (oldsize < (sz - mopts.malloc_guard) / 2)
2075 sz - mopts.malloc_guard, oldsize);
2159 if (!mopts.internal_funcs)
2169 if (mopts.malloc_xmalloc)
2254 if (sz >= SIZE_MAX - mopts.malloc_guard - MALLOC_PAGESIZE) {
2261 sz += mopts.malloc_guard;
2280 if (mopts.malloc_guard) {
2281 if (mprotect((char *)p + psz - mopts.malloc_guard,
2282 mopts.malloc_guard, PROT_NONE))
2284 STATS_ADD(pool->malloc_guarded, mopts.malloc_guard);
2289 memset((char *)p + sz - mopts.malloc_guard,
2292 memset(p, SOME_JUNK, psz - mopts.malloc_guard);
2293 } else if (mopts.chunk_canaries)
2294 fill_canary(p, sz - mopts.malloc_guard,
2295 psz - mopts.malloc_guard);
2327 if (mopts.malloc_xmalloc)
2602 if (mopts.malloc_verbose)
2615 if (mopts.malloc_verbose && p != NULL)
2680 if (mopts.malloc_verbose) {
2702 if (mopts.malloc_verbose)
2708 if (mopts.malloc_verbose)
2717 if (mopts.malloc_verbose)
2752 for (i = 0; i < mopts.malloc_mutexes; i++)
2753 malloc_dump0(i, mopts.malloc_pool[i], &leaks);
2769 mopts.malloc_mutexes,
2770 mopts.internal_funcs, mopts.malloc_freecheck,
2771 mopts.malloc_freeunmap, mopts.def_malloc_junk,
2772 mopts.malloc_realloc, mopts.malloc_xmalloc,
2773 mopts.chunk_canaries, mopts.def_maxcache,
2774 mopts.malloc_guard);