Deleted Added
sdiff udiff text old ( 242844 ) new ( 245868 )
full compact
1#define JEMALLOC_CHUNK_C_
2#include "jemalloc/internal/jemalloc_internal.h"
3
4/******************************************************************************/
5/* Data. */
6
7const char *opt_dss = DSS_DEFAULT;
8size_t opt_lg_chunk = LG_CHUNK_DEFAULT;

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

73 malloc_mutex_unlock(&chunks_mtx);
74 return (NULL);
75 }
76 leadsize = ALIGNMENT_CEILING((uintptr_t)node->addr, alignment) -
77 (uintptr_t)node->addr;
78 assert(node->size >= leadsize + size);
79 trailsize = node->size - leadsize - size;
80 ret = (void *)((uintptr_t)node->addr + leadsize);
81 zeroed = node->zeroed;
82 if (zeroed)
83 *zero = true;
84 /* Remove node from the tree. */
85 extent_tree_szad_remove(chunks_szad, node);
86 extent_tree_ad_remove(chunks_ad, node);
87 if (leadsize != 0) {
88 /* Insert the leading space as a smaller chunk. */
89 node->size = leadsize;
90 extent_tree_szad_insert(chunks_szad, node);
91 extent_tree_ad_insert(chunks_ad, node);

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

112 node->addr = (void *)((uintptr_t)(ret) + size);
113 node->size = trailsize;
114 extent_tree_szad_insert(chunks_szad, node);
115 extent_tree_ad_insert(chunks_ad, node);
116 node = NULL;
117 }
118 malloc_mutex_unlock(&chunks_mtx);
119
120 if (node != NULL)
121 base_node_dealloc(node);
122 VALGRIND_MAKE_MEM_UNDEFINED(ret, size);
123 if (*zero) {
124 if (zeroed == false)
125 memset(ret, 0, size);
126 else if (config_debug) {
127 size_t i;
128 size_t *p = (size_t *)(uintptr_t)ret;
129
130 VALGRIND_MAKE_MEM_DEFINED(ret, size);
131 for (i = 0; i < size / sizeof(size_t); i++)
132 assert(p[i] == 0);
133 VALGRIND_MAKE_MEM_UNDEFINED(ret, size);
134 }
135 }
136 return (ret);
137}
138
139/*
140 * If the caller specifies (*zero == false), it is still possible to receive
141 * zeroed memory, in which case *zero is toggled to true. arena_chunk_alloc()
142 * takes advantage of this to avoid demanding zeroed chunks, but taking
143 * advantage of them if they are returned.

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

196 if (config_prof)
197 gdump = true;
198 } else if (config_prof)
199 gdump = false;
200 malloc_mutex_unlock(&chunks_mtx);
201 if (config_prof && opt_prof && opt_prof_gdump && gdump)
202 prof_gdump();
203 }
204 assert(CHUNK_ADDR2BASE(ret) == ret);
205 return (ret);
206}
207
208static void
209chunk_record(extent_tree_t *chunks_szad, extent_tree_t *chunks_ad, void *chunk,
210 size_t size)
211{

--- 169 unchanged lines hidden ---