Bug 1365460 - Remove support for /etc/malloc.conf. r?njn
While it makes sense for a global system allocator, it's not really
interesting for Firefox to respect that. Plus, newer versions of
jemalloc, which are more likely to be used as a global system allocator
use a different format for the options passed through that file.
--- a/memory/mozjemalloc/mozjemalloc.cpp
+++ b/memory/mozjemalloc/mozjemalloc.cpp
@@ -173,17 +173,16 @@
#include <windows.h>
#include <intrin.h>
#include <algorithm>
#pragma warning( disable: 4267 4996 4146 )
#define SIZE_T_MAX SIZE_MAX
#define STDERR_FILENO 2
-#define PATH_MAX MAX_PATH
#ifndef NO_TLS
static unsigned long tlsIndex = 0xffffffff;
#endif
/* use MSVC intrinsics */
#pragma intrinsic(_BitScanForward)
static __forceinline int
@@ -4683,17 +4682,16 @@ extern "C" void register_zone(void);
#if !defined(MOZ_MEMORY_WINDOWS)
static
#endif
bool
malloc_init_hard(void)
{
unsigned i;
- char buf[PATH_MAX + 1];
const char *opts;
long result;
#ifndef MOZ_MEMORY_WINDOWS
int linklen;
#endif
#ifndef MOZ_MEMORY_WINDOWS
malloc_mutex_lock(&init_lock);
@@ -4741,82 +4739,41 @@ malloc_init_hard(void)
moz_abort();
}
#else
pagesize = (size_t) result;
pagesize_mask = (size_t) result - 1;
pagesize_2pow = ffs((int)result) - 1;
#endif
- for (i = 0; i < 2; i++) {
- unsigned j;
-
- /* Get runtime configuration. */
- switch (i) {
- case 0:
-#ifndef MOZ_MEMORY_WINDOWS
- if ((linklen = readlink("/etc/malloc.conf", buf,
- sizeof(buf) - 1)) != -1) {
- /*
- * Use the contents of the "/etc/malloc.conf"
- * symbolic link's name.
- */
- buf[linklen] = '\0';
- opts = buf;
- } else
-#endif
- {
- /* No configuration specified. */
- buf[0] = '\0';
- opts = buf;
- }
- break;
- case 1:
- if ((opts = getenv("MALLOC_OPTIONS")) != NULL) {
- /*
- * Do nothing; opts is already initialized to
- * the value of the MALLOC_OPTIONS environment
- * variable.
- */
- } else {
- /* No configuration specified. */
- buf[0] = '\0';
- opts = buf;
- }
- break;
- default:
- /* NOTREACHED */
- buf[0] = '\0';
- opts = buf;
- assert(false);
- }
-
- for (j = 0; opts[j] != '\0'; j++) {
- unsigned k, nreps;
+ /* Get runtime configuration. */
+ if ((opts = getenv("MALLOC_OPTIONS")) != NULL) {
+ for (i = 0; opts[i] != '\0'; i++) {
+ unsigned j, nreps;
bool nseen;
/* Parse repetition count, if any. */
- for (nreps = 0, nseen = false;; j++, nseen = true) {
- switch (opts[j]) {
+ for (nreps = 0, nseen = false;; i++, nseen = true) {
+ switch (opts[i]) {
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
case '8': case '9':
nreps *= 10;
- nreps += opts[j] - '0';
+ nreps += opts[i] - '0';
break;
default:
goto MALLOC_OUT;
}
}
MALLOC_OUT:
if (nseen == false)
nreps = 1;
- for (k = 0; k < nreps; k++) {
- switch (opts[j]) {
+ for (j = 0; j < nreps; j++) {
+ switch (opts[i]) {
case 'a':
opt_abort = false;
break;
case 'A':
opt_abort = true;
break;
case 'f':
opt_dirty_max >>= 1;
@@ -4900,17 +4857,17 @@ MALLOC_OUT:
break;
case 'Z':
opt_zero = true;
break;
#endif
default: {
char cbuf[2];
- cbuf[0] = opts[j];
+ cbuf[0] = opts[i];
cbuf[1] = '\0';
_malloc_message(_getprogname(),
": (malloc) Unsupported character "
"in malloc options: '", cbuf,
"'\n");
}
}
}