mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-23 21:23:06 +00:00
Port to FreeBSD.
Use FreeBSD-specific functions (_pthread_mutex_init_calloc_cb(),
_malloc_{pre,post}fork()) to avoid bootstrapping issues due to
allocation in libc and libthr.
Add malloc_strtoumax() and use it instead of strtoul(). Disable
validation code in malloc_vsnprintf() and malloc_strtoumax() until
jemalloc is initialized. This is necessary because locale
initialization causes allocation for both vsnprintf() and strtoumax().
Force the lazy-lock feature on in order to avoid pthread_self(),
because it causes allocation.
Use syscall(SYS_write, ...) rather than write(...), because libthr wraps
write() and causes allocation. Without this workaround, it would not be
possible to print error messages in malloc_conf_init() without
substantially reworking bootstrapping.
Fix choose_arena_hard() to look at how many threads are assigned to the
candidate choice, rather than checking whether the arena is
uninitialized. This bug potentially caused more arenas to be
initialized than necessary.
This commit is contained in:
@@ -615,19 +615,19 @@ ctl_lookup(const char *name, ctl_node_t const **nodesp, size_t *mibp,
|
||||
goto RETURN;
|
||||
}
|
||||
} else {
|
||||
unsigned long index;
|
||||
uintmax_t index;
|
||||
const ctl_node_t *inode;
|
||||
|
||||
/* Children are indexed. */
|
||||
index = strtoul(elm, NULL, 10);
|
||||
if (index == ULONG_MAX) {
|
||||
index = malloc_strtoumax(elm, NULL, 10);
|
||||
if (index == UINTMAX_MAX || index > SIZE_T_MAX) {
|
||||
ret = ENOENT;
|
||||
goto RETURN;
|
||||
}
|
||||
|
||||
inode = &node->u.named.children[0];
|
||||
node = inode->u.indexed.index(mibp, *depthp,
|
||||
index);
|
||||
(size_t)index);
|
||||
if (node == NULL) {
|
||||
ret = ENOENT;
|
||||
goto RETURN;
|
||||
|
||||
Reference in New Issue
Block a user