File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -206,9 +206,7 @@ namespace snmalloc
206
206
*/
207
207
size_t cache_bytes{REMOTE_CACHE};
208
208
209
- #ifndef NDEBUG
210
209
bool initialised = false ;
211
- #endif
212
210
213
211
// / Used to find the index into the array of queues for remote
214
212
// / deallocation
@@ -238,8 +236,21 @@ namespace snmalloc
238
236
239
237
size_t size = n * sizeclass_full_to_size (entry.get_sizeclass ());
240
238
241
- cache_bytes += size;
242
- return cache_bytes < REMOTE_CACHE;
239
+ size_t new_cache_bytes = cache_bytes + size;
240
+ if (SNMALLOC_UNLIKELY (new_cache_bytes > REMOTE_CACHE))
241
+ {
242
+ // Check if this is the default allocator, and if not, we
243
+ // can update the state.
244
+ if (initialised)
245
+ {
246
+ cache_bytes = new_cache_bytes;
247
+ }
248
+
249
+ return false ;
250
+ }
251
+
252
+ cache_bytes = new_cache_bytes;
253
+ return true ;
243
254
}
244
255
245
256
template <size_t allocator_size>
@@ -376,9 +387,8 @@ namespace snmalloc
376
387
*/
377
388
void init ()
378
389
{
379
- #ifndef NDEBUG
380
390
initialised = true ;
381
- # endif
391
+
382
392
for (auto & l : list)
383
393
{
384
394
// We do not need to initialise with a particular slab, so pass
You can’t perform that action at this time.
0 commit comments