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
206206 */
207207 size_t cache_bytes{REMOTE_CACHE};
208208
209- #ifndef NDEBUG
210209 bool initialised = false ;
211- #endif
212210
213211 // / Used to find the index into the array of queues for remote
214212 // / deallocation
@@ -238,8 +236,21 @@ namespace snmalloc
238236
239237 size_t size = n * sizeclass_full_to_size (entry.get_sizeclass ());
240238
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 ;
243254 }
244255
245256 template <size_t allocator_size>
@@ -376,9 +387,8 @@ namespace snmalloc
376387 */
377388 void init ()
378389 {
379- #ifndef NDEBUG
380390 initialised = true ;
381- # endif
391+
382392 for (auto & l : list)
383393 {
384394 // We do not need to initialise with a particular slab, so pass
You can’t perform that action at this time.
0 commit comments