chunk.c (242844) | chunk.c (245868) |
---|---|
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); | 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; |
|
81 /* Remove node from the tree. */ 82 extent_tree_szad_remove(chunks_szad, node); 83 extent_tree_ad_remove(chunks_ad, node); 84 if (leadsize != 0) { 85 /* Insert the leading space as a smaller chunk. */ 86 node->size = leadsize; 87 extent_tree_szad_insert(chunks_szad, node); 88 extent_tree_ad_insert(chunks_ad, node); --- 20 unchanged lines hidden (view full) --- 109 node->addr = (void *)((uintptr_t)(ret) + size); 110 node->size = trailsize; 111 extent_tree_szad_insert(chunks_szad, node); 112 extent_tree_ad_insert(chunks_ad, node); 113 node = NULL; 114 } 115 malloc_mutex_unlock(&chunks_mtx); 116 | 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 |
117 zeroed = false; 118 if (node != NULL) { 119 if (node->zeroed) { 120 zeroed = true; 121 *zero = true; 122 } | 120 if (node != NULL) |
123 base_node_dealloc(node); | 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 } |
|
124 } | 135 } |
125 if (zeroed == false && *zero) { 126 VALGRIND_MAKE_MEM_UNDEFINED(ret, size); 127 memset(ret, 0, size); 128 } | |
129 return (ret); 130} 131 132/* 133 * If the caller specifies (*zero == false), it is still possible to receive 134 * zeroed memory, in which case *zero is toggled to true. arena_chunk_alloc() 135 * takes advantage of this to avoid demanding zeroed chunks, but taking 136 * advantage of them if they are returned. --- 52 unchanged lines hidden (view full) --- 189 if (config_prof) 190 gdump = true; 191 } else if (config_prof) 192 gdump = false; 193 malloc_mutex_unlock(&chunks_mtx); 194 if (config_prof && opt_prof && opt_prof_gdump && gdump) 195 prof_gdump(); 196 } | 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 } |
197 if (config_debug && *zero && ret != NULL) { 198 size_t i; 199 size_t *p = (size_t *)(uintptr_t)ret; 200 201 VALGRIND_MAKE_MEM_DEFINED(ret, size); 202 for (i = 0; i < size / sizeof(size_t); i++) 203 assert(p[i] == 0); 204 } | |
205 assert(CHUNK_ADDR2BASE(ret) == ret); 206 return (ret); 207} 208 209static void 210chunk_record(extent_tree_t *chunks_szad, extent_tree_t *chunks_ad, void *chunk, 211 size_t size) 212{ --- 169 unchanged lines hidden --- | 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 --- |