Deleted Added
full compact
jemalloc.c (251300) jemalloc.c (256823)
1#define JEMALLOC_C_
2#include "jemalloc/internal/jemalloc_internal.h"
3
4/******************************************************************************/
5/* Data. */
6
7malloc_tsd_data(, arenas, arena_t *, NULL)
8malloc_tsd_data(, thread_allocated, thread_allocated_t,

--- 272 unchanged lines hidden (view full) ---

281{
282 arena_t *arena = *(arena_t **)arg;
283
284 malloc_mutex_lock(&arenas_lock);
285 arena->nthreads--;
286 malloc_mutex_unlock(&arenas_lock);
287}
288
1#define JEMALLOC_C_
2#include "jemalloc/internal/jemalloc_internal.h"
3
4/******************************************************************************/
5/* Data. */
6
7malloc_tsd_data(, arenas, arena_t *, NULL)
8malloc_tsd_data(, thread_allocated, thread_allocated_t,

--- 272 unchanged lines hidden (view full) ---

281{
282 arena_t *arena = *(arena_t **)arg;
283
284 malloc_mutex_lock(&arenas_lock);
285 arena->nthreads--;
286 malloc_mutex_unlock(&arenas_lock);
287}
288
289static JEMALLOC_ATTR(always_inline) void
289JEMALLOC_ALWAYS_INLINE_C void
290malloc_thread_init(void)
291{
292
293 /*
294 * TSD initialization can't be safely done as a side effect of
295 * deallocation, because it is possible for a thread to do nothing but
296 * deallocate its TLS data via free(), in which case writing to TLS
297 * would cause write-after-free memory corruption. The quarantine
298 * facility *only* gets used as a side effect of deallocation, so make
299 * a best effort attempt at initializing its TSD by hooking all
300 * allocation events.
301 */
302 if (config_fill && opt_quarantine)
303 quarantine_alloc_hook();
304}
305
290malloc_thread_init(void)
291{
292
293 /*
294 * TSD initialization can't be safely done as a side effect of
295 * deallocation, because it is possible for a thread to do nothing but
296 * deallocate its TLS data via free(), in which case writing to TLS
297 * would cause write-after-free memory corruption. The quarantine
298 * facility *only* gets used as a side effect of deallocation, so make
299 * a best effort attempt at initializing its TSD by hooking all
300 * allocation events.
301 */
302 if (config_fill && opt_quarantine)
303 quarantine_alloc_hook();
304}
305
306static JEMALLOC_ATTR(always_inline) bool
306JEMALLOC_ALWAYS_INLINE_C bool
307malloc_init(void)
308{
309
310 if (malloc_initialized == false && malloc_init_hard())
311 return (true);
312 malloc_thread_init();
313
314 return (false);

--- 120 unchanged lines hidden (view full) ---

435 opts = je_malloc_conf;
436 } else {
437 /* No configuration specified. */
438 buf[0] = '\0';
439 opts = buf;
440 }
441 break;
442 case 1: {
307malloc_init(void)
308{
309
310 if (malloc_initialized == false && malloc_init_hard())
311 return (true);
312 malloc_thread_init();
313
314 return (false);

--- 120 unchanged lines hidden (view full) ---

435 opts = je_malloc_conf;
436 } else {
437 /* No configuration specified. */
438 buf[0] = '\0';
439 opts = buf;
440 }
441 break;
442 case 1: {
443 int linklen = 0;
443#ifndef _WIN32
444#ifndef _WIN32
444 int linklen;
445 int saved_errno = errno;
445 const char *linkname =
446# ifdef JEMALLOC_PREFIX
447 "/etc/"JEMALLOC_PREFIX"malloc.conf"
448# else
449 "/etc/malloc.conf"
450# endif
451 ;
452
446 const char *linkname =
447# ifdef JEMALLOC_PREFIX
448 "/etc/"JEMALLOC_PREFIX"malloc.conf"
449# else
450 "/etc/malloc.conf"
451# endif
452 ;
453
453 if ((linklen = readlink(linkname, buf,
454 sizeof(buf) - 1)) != -1) {
455 /*
456 * Use the contents of the "/etc/malloc.conf"
457 * symbolic link's name.
458 */
459 buf[linklen] = '\0';
460 opts = buf;
461 } else
462#endif
463 {
454 /*
455 * Try to use the contents of the "/etc/malloc.conf"
456 * symbolic link's name.
457 */
458 linklen = readlink(linkname, buf, sizeof(buf) - 1);
459 if (linklen == -1) {
464 /* No configuration specified. */
460 /* No configuration specified. */
465 buf[0] = '\0';
466 opts = buf;
461 linklen = 0;
462 /* restore errno */
463 set_errno(saved_errno);
467 }
464 }
465#endif
466 buf[linklen] = '\0';
467 opts = buf;
468 break;
469 } case 2: {
470 const char *envname =
471#ifdef JEMALLOC_PREFIX
472 JEMALLOC_CPREFIX"MALLOC_CONF"
473#else
474 "MALLOC_CONF"
475#endif

--- 926 unchanged lines hidden (view full) ---

1402 * End non-standard functions.
1403 */
1404/******************************************************************************/
1405/*
1406 * Begin experimental functions.
1407 */
1408#ifdef JEMALLOC_EXPERIMENTAL
1409
468 break;
469 } case 2: {
470 const char *envname =
471#ifdef JEMALLOC_PREFIX
472 JEMALLOC_CPREFIX"MALLOC_CONF"
473#else
474 "MALLOC_CONF"
475#endif

--- 926 unchanged lines hidden (view full) ---

1402 * End non-standard functions.
1403 */
1404/******************************************************************************/
1405/*
1406 * Begin experimental functions.
1407 */
1408#ifdef JEMALLOC_EXPERIMENTAL
1409
1410static JEMALLOC_ATTR(always_inline) void *
1410JEMALLOC_ALWAYS_INLINE_C void *
1411iallocm(size_t usize, size_t alignment, bool zero, bool try_tcache,
1412 arena_t *arena)
1413{
1414
1415 assert(usize == ((alignment == 0) ? s2u(usize) : sa2u(usize,
1416 alignment)));
1417
1418 if (alignment != 0)

--- 455 unchanged lines hidden ---
1411iallocm(size_t usize, size_t alignment, bool zero, bool try_tcache,
1412 arena_t *arena)
1413{
1414
1415 assert(usize == ((alignment == 0) ? s2u(usize) : sa2u(usize,
1416 alignment)));
1417
1418 if (alignment != 0)

--- 455 unchanged lines hidden ---