tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 39db3f6e0d5482c22ab2ebe9e51259420c7c227e
parent f22bc7265e0d693110bbc2c5b730684299da2ab7
Author: Paul Bone <paul@bone.id.au>
Date:   Wed, 29 Oct 2025 06:32:45 +0000

Bug 1976162 - pt 5. Refactor TypeBaseAlloc's free list check r=glandium

Refactor this function so that it can use MutexAutoLock.

Differential Revision: https://phabricator.services.mozilla.com/D256416

Diffstat:
Mmemory/build/BaseAlloc.h | 19++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/memory/build/BaseAlloc.h b/memory/build/BaseAlloc.h @@ -61,19 +61,16 @@ struct TypedBaseAlloc { static size_t size_of() { return sizeof(T); } static T* alloc() { - T* ret; - - sBaseAlloc.mMutex.Lock(); - if (sFirstFree) { - ret = sFirstFree; - sFirstFree = *(T**)ret; - sBaseAlloc.mMutex.Unlock(); - } else { - sBaseAlloc.mMutex.Unlock(); - ret = (T*)sBaseAlloc.alloc(size_of()); + { + MutexAutoLock lock(sBaseAlloc.mMutex); + T* ret = sFirstFree; + if (ret) { + sFirstFree = *(T**)ret; + return ret; + } } - return ret; + return (T*)sBaseAlloc.alloc(size_of()); } static void dealloc(T* aNode) {