Browse Source

Allocator: not bind, replace count type from signed to unsigned (#2944)

Related: https://github.com/urho3d/Urho3D/issues/2940
1vanK 3 years ago
parent
commit
1143e19fc3

+ 0 - 22
Docs/AngelScriptAPI.h

@@ -22,28 +22,6 @@
 
 
 // Classes
 // Classes
 
 
-class AllocatorBlock
-{
-public:
-~AllocatorBlock();
-AllocatorBlock();
-// Methods:
-AllocatorBlock&  operator=(const AllocatorBlock&);
-
-// Properties:
-uint capacity;
-uint nodeSize;
-};
-
-class AllocatorNode
-{
-public:
-~AllocatorNode();
-AllocatorNode();
-// Methods:
-AllocatorNode&  operator=(const AllocatorNode&);
-};
-
 class Animatable
 class Animatable
 {
 {
 public:
 public:

+ 0 - 23
Docs/ScriptAPI.dox

@@ -2766,8 +2766,6 @@ namespace Urho3D
 
 
 \section ScriptAPI_ClassList Class list
 \section ScriptAPI_ClassList Class list
 
 
-<a href="#Class_AllocatorBlock"><b>AllocatorBlock</b></a>
-<a href="#Class_AllocatorNode"><b>AllocatorNode</b></a>
 <a href="#Class_Animatable"><b>Animatable</b></a>
 <a href="#Class_Animatable"><b>Animatable</b></a>
 <a href="#Class_AnimatedModel"><b>AnimatedModel</b></a>
 <a href="#Class_AnimatedModel"><b>AnimatedModel</b></a>
 <a href="#Class_AnimatedSprite2D"><b>AnimatedSprite2D</b></a>
 <a href="#Class_AnimatedSprite2D"><b>AnimatedSprite2D</b></a>
@@ -3113,27 +3111,6 @@ namespace Urho3D
 <a href="#Class_Zone"><b>Zone</b></a>
 <a href="#Class_Zone"><b>Zone</b></a>
 
 
 \section ScriptAPI_Classes Classes
 \section ScriptAPI_Classes Classes
-<a name="Class_AllocatorBlock"></a>
-
-### AllocatorBlock
-
-Methods:
-
-- AllocatorBlock&  operator=(const AllocatorBlock&)
-
-Properties:
-
-- uint capacity
-- uint nodeSize
-
-<a name="Class_AllocatorNode"></a>
-
-### AllocatorNode
-
-Methods:
-
-- AllocatorNode&  operator=(const AllocatorNode&)
-
 <a name="Class_Animatable"></a>
 <a name="Class_Animatable"></a>
 
 
 ### Animatable
 ### Animatable

+ 0 - 34
Source/Urho3D/AngelScript/Generated_Classes.cpp

@@ -10,38 +10,6 @@
 namespace Urho3D
 namespace Urho3D
 {
 {
 
 
-// struct AllocatorBlock | File: ../Container/Allocator.h
-static void Register_AllocatorBlock(asIScriptEngine* engine)
-{
-    // AllocatorBlock::~AllocatorBlock() | Implicitly-declared
-    engine->RegisterObjectBehaviour("AllocatorBlock", asBEHAVE_DESTRUCT, "void f()", AS_DESTRUCTOR(AllocatorBlock), AS_CALL_CDECL_OBJFIRST);
-
-    RegisterMembers_AllocatorBlock<AllocatorBlock>(engine, "AllocatorBlock");
-
-    #ifdef REGISTER_CLASS_MANUAL_PART_AllocatorBlock
-        REGISTER_CLASS_MANUAL_PART_AllocatorBlock();
-    #endif
-
-    // AllocatorBlock& AllocatorBlock::operator =(const AllocatorBlock&) | Possible implicitly-declared
-    RegisterImplicitlyDeclaredAssignOperatorIfPossible<AllocatorBlock>(engine, "AllocatorBlock");
-}
-
-// struct AllocatorNode | File: ../Container/Allocator.h
-static void Register_AllocatorNode(asIScriptEngine* engine)
-{
-    // AllocatorNode::~AllocatorNode() | Implicitly-declared
-    engine->RegisterObjectBehaviour("AllocatorNode", asBEHAVE_DESTRUCT, "void f()", AS_DESTRUCTOR(AllocatorNode), AS_CALL_CDECL_OBJFIRST);
-
-    RegisterMembers_AllocatorNode<AllocatorNode>(engine, "AllocatorNode");
-
-    #ifdef REGISTER_CLASS_MANUAL_PART_AllocatorNode
-        REGISTER_CLASS_MANUAL_PART_AllocatorNode();
-    #endif
-
-    // AllocatorNode& AllocatorNode::operator =(const AllocatorNode&) | Possible implicitly-declared
-    RegisterImplicitlyDeclaredAssignOperatorIfPossible<AllocatorNode>(engine, "AllocatorNode");
-}
-
 // struct AnimationControl | File: ../Graphics/AnimationController.h
 // struct AnimationControl | File: ../Graphics/AnimationController.h
 static void Register_AnimationControl(asIScriptEngine* engine)
 static void Register_AnimationControl(asIScriptEngine* engine)
 {
 {
@@ -8397,8 +8365,6 @@ static void Register_StretchableSprite2D(asIScriptEngine* engine)
 
 
 void ASRegisterGeneratedClasses(asIScriptEngine* engine)
 void ASRegisterGeneratedClasses(asIScriptEngine* engine)
 {
 {
-    Register_AllocatorBlock(engine);
-    Register_AllocatorNode(engine);
     Register_AnimationControl(engine);
     Register_AnimationControl(engine);
     Register_AnimationKeyFrame(engine);
     Register_AnimationKeyFrame(engine);
     Register_AnimationStateTrack(engine);
     Register_AnimationStateTrack(engine);

+ 0 - 6
Source/Urho3D/AngelScript/Generated_DefaultConstructors.cpp

@@ -12,12 +12,6 @@ namespace Urho3D
 
 
 void ASRegisterGeneratedDefaultConstructors(asIScriptEngine* engine)
 void ASRegisterGeneratedDefaultConstructors(asIScriptEngine* engine)
 {
 {
-    // AllocatorBlock::AllocatorBlock() | Implicitly-declared
-    engine->RegisterObjectBehaviour("AllocatorBlock", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ASCompatibleConstructor<AllocatorBlock>), AS_CALL_CDECL_OBJFIRST);
-
-    // AllocatorNode::AllocatorNode() | Implicitly-declared
-    engine->RegisterObjectBehaviour("AllocatorNode", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ASCompatibleConstructor<AllocatorNode>), AS_CALL_CDECL_OBJFIRST);
-
     // AnimationKeyFrame::AnimationKeyFrame() | File: ../Graphics/Animation.h
     // AnimationKeyFrame::AnimationKeyFrame() | File: ../Graphics/Animation.h
     engine->RegisterObjectBehaviour("AnimationKeyFrame", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ASCompatibleConstructor<AnimationKeyFrame>), AS_CALL_CDECL_OBJFIRST);
     engine->RegisterObjectBehaviour("AnimationKeyFrame", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ASCompatibleConstructor<AnimationKeyFrame>), AS_CALL_CDECL_OBJFIRST);
 
 

+ 0 - 12
Source/Urho3D/AngelScript/Generated_GlobalFunctions.cpp

@@ -44,18 +44,6 @@ void ASRegisterGeneratedGlobalFunctions(asIScriptEngine* engine)
     // String AddTrailingSlash(const String& pathName) | File: ../IO/FileSystem.h
     // String AddTrailingSlash(const String& pathName) | File: ../IO/FileSystem.h
     engine->RegisterGlobalFunction("String AddTrailingSlash(const String&in)", AS_FUNCTIONPR(AddTrailingSlash, (const String&), String), AS_CALL_CDECL);
     engine->RegisterGlobalFunction("String AddTrailingSlash(const String&in)", AS_FUNCTIONPR(AddTrailingSlash, (const String&), String), AS_CALL_CDECL);
 
 
-    // void AllocatorFree(AllocatorBlock* allocator, void* ptr) | File: ../Container/Allocator.h
-    // Error: type "AllocatorBlock*" can not automatically bind
-
-    // AllocatorBlock* AllocatorInitialize(unsigned nodeSize, unsigned initialCapacity = 1) | File: ../Container/Allocator.h
-    // Error: type "AllocatorBlock*" can not automatically bind
-
-    // void* AllocatorReserve(AllocatorBlock* allocator) | File: ../Container/Allocator.h
-    // Error: type "AllocatorBlock*" can not automatically bind
-
-    // void AllocatorUninitialize(AllocatorBlock* allocator) | File: ../Container/Allocator.h
-    // Error: type "AllocatorBlock*" can not automatically bind
-
     // template <class T> T Asin(T x) | File: ../Math/MathDefs.h
     // template <class T> T Asin(T x) | File: ../Math/MathDefs.h
     engine->RegisterGlobalFunction("float Asin(float)", AS_FUNCTIONPR(Asin, (float), float), AS_CALL_CDECL);
     engine->RegisterGlobalFunction("float Asin(float)", AS_FUNCTIONPR(Asin, (float), float), AS_CALL_CDECL);
 
 

+ 1 - 1
Source/Urho3D/AngelScript/Generated_Includes.h

@@ -11,7 +11,6 @@
 #include "../Audio/SoundSource.h"
 #include "../Audio/SoundSource.h"
 #include "../Audio/SoundSource3D.h"
 #include "../Audio/SoundSource3D.h"
 #include "../Audio/SoundStream.h"
 #include "../Audio/SoundStream.h"
-#include "../Container/Allocator.h"
 #include "../Container/Hash.h"
 #include "../Container/Hash.h"
 #include "../Container/HashBase.h"
 #include "../Container/HashBase.h"
 #include "../Container/LinkedList.h"
 #include "../Container/LinkedList.h"
@@ -265,6 +264,7 @@
 
 
 // Ignored headers
 // Ignored headers
 
 
+//#include "../Container/Allocator.h"
 //#include "../Database/ODBC/ODBCConnection.h"
 //#include "../Database/ODBC/ODBCConnection.h"
 //#include "../Database/ODBC/ODBCResult.h"
 //#include "../Database/ODBC/ODBCResult.h"
 //#include "../Engine/Application.h"
 //#include "../Engine/Application.h"

+ 0 - 30
Source/Urho3D/AngelScript/Generated_Members.h

@@ -10,36 +10,6 @@
 namespace Urho3D
 namespace Urho3D
 {
 {
 
 
-// struct AllocatorBlock | File: ../Container/Allocator.h
-template <class T> void RegisterMembers_AllocatorBlock(asIScriptEngine* engine, const char* className)
-{
-    // AllocatorNode* AllocatorBlock::free_
-    // Not registered because pointer
-    // AllocatorBlock* AllocatorBlock::next_
-    // Not registered because pointer
-
-    // unsigned AllocatorBlock::nodeSize_
-    engine->RegisterObjectProperty(className, "uint nodeSize", offsetof(T, nodeSize_));
-
-    // unsigned AllocatorBlock::capacity_
-    engine->RegisterObjectProperty(className, "uint capacity", offsetof(T, capacity_));
-
-    #ifdef REGISTER_MEMBERS_MANUAL_PART_AllocatorBlock
-        REGISTER_MEMBERS_MANUAL_PART_AllocatorBlock();
-    #endif
-}
-
-// struct AllocatorNode | File: ../Container/Allocator.h
-template <class T> void RegisterMembers_AllocatorNode(asIScriptEngine* engine, const char* className)
-{
-    // AllocatorNode* AllocatorNode::next_
-    // Not registered because pointer
-
-    #ifdef REGISTER_MEMBERS_MANUAL_PART_AllocatorNode
-        REGISTER_MEMBERS_MANUAL_PART_AllocatorNode();
-    #endif
-}
-
 // struct AnimationControl | File: ../Graphics/AnimationController.h
 // struct AnimationControl | File: ../Graphics/AnimationController.h
 template <class T> void RegisterMembers_AnimationControl(asIScriptEngine* engine, const char* className)
 template <class T> void RegisterMembers_AnimationControl(asIScriptEngine* engine, const char* className)
 {
 {

+ 0 - 6
Source/Urho3D/AngelScript/Generated_ObjectTypes.cpp

@@ -12,12 +12,6 @@ namespace Urho3D
 
 
 void ASRegisterGeneratedObjectTypes(asIScriptEngine* engine)
 void ASRegisterGeneratedObjectTypes(asIScriptEngine* engine)
 {
 {
-    // struct AllocatorBlock | File: ../Container/Allocator.h
-    engine->RegisterObjectType("AllocatorBlock", sizeof(AllocatorBlock), asOBJ_VALUE | asGetTypeTraits<AllocatorBlock>());
-
-    // struct AllocatorNode | File: ../Container/Allocator.h
-    engine->RegisterObjectType("AllocatorNode", sizeof(AllocatorNode), asOBJ_VALUE | asGetTypeTraits<AllocatorNode>());
-
     // struct AnimationControl | File: ../Graphics/AnimationController.h
     // struct AnimationControl | File: ../Graphics/AnimationController.h
     engine->RegisterObjectType("AnimationControl", 0, asOBJ_REF | asOBJ_NOCOUNT);
     engine->RegisterObjectType("AnimationControl", 0, asOBJ_REF | asOBJ_NOCOUNT);
 
 

+ 19 - 18
Source/Urho3D/Container/Allocator.cpp

@@ -8,20 +8,21 @@
 namespace Urho3D
 namespace Urho3D
 {
 {
 
 
-AllocatorBlock* AllocatorReserveBlock(AllocatorBlock* allocator, unsigned nodeSize, unsigned capacity)
+static AllocatorBlock* AllocatorReserveBlock(AllocatorBlock* allocator, i32 nodeSize, i32 capacity)
 {
 {
-    if (!capacity)
-        capacity = 1;
+    assert(nodeSize > 0 && capacity > 0);
 
 
-    auto* blockPtr = new unsigned char[sizeof(AllocatorBlock) + capacity * (sizeof(AllocatorNode) + nodeSize)];
-    auto* newBlock = reinterpret_cast<AllocatorBlock*>(blockPtr);
+    u8* blockPtr = new u8[sizeof(AllocatorBlock) + capacity * (sizeof(AllocatorNode) + nodeSize)];
+    AllocatorBlock* newBlock = reinterpret_cast<AllocatorBlock*>(blockPtr);
     newBlock->nodeSize_ = nodeSize;
     newBlock->nodeSize_ = nodeSize;
     newBlock->capacity_ = capacity;
     newBlock->capacity_ = capacity;
     newBlock->free_ = nullptr;
     newBlock->free_ = nullptr;
     newBlock->next_ = nullptr;
     newBlock->next_ = nullptr;
 
 
     if (!allocator)
     if (!allocator)
+    {
         allocator = newBlock;
         allocator = newBlock;
+    }
     else
     else
     {
     {
         newBlock->next_ = allocator->next_;
         newBlock->next_ = allocator->next_;
@@ -29,18 +30,19 @@ AllocatorBlock* AllocatorReserveBlock(AllocatorBlock* allocator, unsigned nodeSi
     }
     }
 
 
     // Initialize the nodes. Free nodes are always chained to the first (parent) allocator
     // Initialize the nodes. Free nodes are always chained to the first (parent) allocator
-    unsigned char* nodePtr = blockPtr + sizeof(AllocatorBlock);
-    auto* firstNewNode = reinterpret_cast<AllocatorNode*>(nodePtr);
+    u8* nodePtr = blockPtr + sizeof(AllocatorBlock);
+    AllocatorNode* firstNewNode = reinterpret_cast<AllocatorNode*>(nodePtr);
 
 
-    for (unsigned i = 0; i < capacity - 1; ++i)
+    for (i32 i = 0; i < capacity - 1; ++i)
     {
     {
-        auto* newNode = reinterpret_cast<AllocatorNode*>(nodePtr);
+        AllocatorNode* newNode = reinterpret_cast<AllocatorNode*>(nodePtr);
         newNode->next_ = reinterpret_cast<AllocatorNode*>(nodePtr + sizeof(AllocatorNode) + nodeSize);
         newNode->next_ = reinterpret_cast<AllocatorNode*>(nodePtr + sizeof(AllocatorNode) + nodeSize);
         nodePtr += sizeof(AllocatorNode) + nodeSize;
         nodePtr += sizeof(AllocatorNode) + nodeSize;
     }
     }
+    
     // i == capacity - 1
     // i == capacity - 1
     {
     {
-        auto* newNode = reinterpret_cast<AllocatorNode*>(nodePtr);
+        AllocatorNode* newNode = reinterpret_cast<AllocatorNode*>(nodePtr);
         newNode->next_ = nullptr;
         newNode->next_ = nullptr;
     }
     }
 
 
@@ -49,10 +51,9 @@ AllocatorBlock* AllocatorReserveBlock(AllocatorBlock* allocator, unsigned nodeSi
     return newBlock;
     return newBlock;
 }
 }
 
 
-AllocatorBlock* AllocatorInitialize(unsigned nodeSize, unsigned initialCapacity)
+AllocatorBlock* AllocatorInitialize(i32 nodeSize, i32 initialCapacity)
 {
 {
-    AllocatorBlock* block = AllocatorReserveBlock(nullptr, nodeSize, initialCapacity);
-    return block;
+    return AllocatorReserveBlock(nullptr, nodeSize, initialCapacity);
 }
 }
 
 
 void AllocatorUninitialize(AllocatorBlock* allocator)
 void AllocatorUninitialize(AllocatorBlock* allocator)
@@ -60,7 +61,7 @@ void AllocatorUninitialize(AllocatorBlock* allocator)
     while (allocator)
     while (allocator)
     {
     {
         AllocatorBlock* next = allocator->next_;
         AllocatorBlock* next = allocator->next_;
-        delete[] reinterpret_cast<unsigned char*>(allocator);
+        delete[] reinterpret_cast<u8*>(allocator);
         allocator = next;
         allocator = next;
     }
     }
 }
 }
@@ -73,14 +74,14 @@ void* AllocatorReserve(AllocatorBlock* allocator)
     if (!allocator->free_)
     if (!allocator->free_)
     {
     {
         // Free nodes have been exhausted. Allocate a new larger block
         // Free nodes have been exhausted. Allocate a new larger block
-        unsigned newCapacity = (allocator->capacity_ + 1) >> 1u;
+        i32 newCapacity = (allocator->capacity_ + 1) >> 1u; // * 0.5 and round up
         AllocatorReserveBlock(allocator, allocator->nodeSize_, newCapacity);
         AllocatorReserveBlock(allocator, allocator->nodeSize_, newCapacity);
         allocator->capacity_ += newCapacity;
         allocator->capacity_ += newCapacity;
     }
     }
 
 
     // We should have new free node(s) chained
     // We should have new free node(s) chained
     AllocatorNode* freeNode = allocator->free_;
     AllocatorNode* freeNode = allocator->free_;
-    void* ptr = (reinterpret_cast<unsigned char*>(freeNode)) + sizeof(AllocatorNode);
+    void* ptr = reinterpret_cast<u8*>(freeNode) + sizeof(AllocatorNode);
     allocator->free_ = freeNode->next_;
     allocator->free_ = freeNode->next_;
     freeNode->next_ = nullptr;
     freeNode->next_ = nullptr;
 
 
@@ -92,8 +93,8 @@ void AllocatorFree(AllocatorBlock* allocator, void* ptr)
     if (!allocator || !ptr)
     if (!allocator || !ptr)
         return;
         return;
 
 
-    auto* dataPtr = static_cast<unsigned char*>(ptr);
-    auto* node = reinterpret_cast<AllocatorNode*>(dataPtr - sizeof(AllocatorNode));
+    u8* dataPtr = static_cast<u8*>(ptr);
+    AllocatorNode* node = reinterpret_cast<AllocatorNode*>(dataPtr - sizeof(AllocatorNode));
 
 
     // Chain the node back to free nodes
     // Chain the node back to free nodes
     node->next_ = allocator->free_;
     node->next_ = allocator->free_;

+ 30 - 17
Source/Urho3D/Container/Allocator.h

@@ -1,6 +1,9 @@
 // Copyright (c) 2008-2022 the Urho3D project
 // Copyright (c) 2008-2022 the Urho3D project
 // License: MIT
 // License: MIT
 
 
+/// \file
+/// @nobindfile
+
 #pragma once
 #pragma once
 
 
 #ifdef URHO3D_IS_BUILDING
 #ifdef URHO3D_IS_BUILDING
@@ -16,21 +19,24 @@
 namespace Urho3D
 namespace Urho3D
 {
 {
 
 
-struct AllocatorBlock;
 struct AllocatorNode;
 struct AllocatorNode;
 
 
 /// %Allocator memory block.
 /// %Allocator memory block.
 struct AllocatorBlock
 struct AllocatorBlock
 {
 {
     /// Size of a node.
     /// Size of a node.
-    unsigned nodeSize_;
+    i32 nodeSize_;
+
     /// Number of nodes in this block.
     /// Number of nodes in this block.
-    unsigned capacity_;
+    i32 capacity_;
+
     /// First free node.
     /// First free node.
     AllocatorNode* free_;
     AllocatorNode* free_;
+
     /// Next allocator block.
     /// Next allocator block.
     AllocatorBlock* next_;
     AllocatorBlock* next_;
-    /// Nodes follow.
+
+    // Nodes follow
 };
 };
 
 
 /// %Allocator node.
 /// %Allocator node.
@@ -38,28 +44,36 @@ struct AllocatorNode
 {
 {
     /// Next free node.
     /// Next free node.
     AllocatorNode* next_;
     AllocatorNode* next_;
-    /// Data follows.
+
+    // Data follows
 };
 };
 
 
 /// Initialize a fixed-size allocator with the node size and initial capacity.
 /// Initialize a fixed-size allocator with the node size and initial capacity.
-URHO3D_API AllocatorBlock* AllocatorInitialize(unsigned nodeSize, unsigned initialCapacity = 1);
+URHO3D_API AllocatorBlock* AllocatorInitialize(i32 nodeSize, i32 initialCapacity = 1);
+
 /// Uninitialize a fixed-size allocator. Frees all blocks in the chain.
 /// Uninitialize a fixed-size allocator. Frees all blocks in the chain.
 URHO3D_API void AllocatorUninitialize(AllocatorBlock* allocator);
 URHO3D_API void AllocatorUninitialize(AllocatorBlock* allocator);
+
 /// Reserve a node. Creates a new block if necessary.
 /// Reserve a node. Creates a new block if necessary.
 URHO3D_API void* AllocatorReserve(AllocatorBlock* allocator);
 URHO3D_API void* AllocatorReserve(AllocatorBlock* allocator);
+
 /// Free a node. Does not free any blocks.
 /// Free a node. Does not free any blocks.
 URHO3D_API void AllocatorFree(AllocatorBlock* allocator, void* ptr);
 URHO3D_API void AllocatorFree(AllocatorBlock* allocator, void* ptr);
 
 
 /// %Allocator template class. Allocates objects of a specific class.
 /// %Allocator template class. Allocates objects of a specific class.
 template <class T> class Allocator
 template <class T> class Allocator
 {
 {
+private:
+    /// Allocator block.
+    AllocatorBlock* allocator_;
+
 public:
 public:
     /// Construct.
     /// Construct.
-    explicit Allocator(unsigned initialCapacity = 0) :
-        allocator_(nullptr)
+    explicit Allocator(i32 initialCapacity = 0)
+        : allocator_(nullptr)
     {
     {
         if (initialCapacity)
         if (initialCapacity)
-            allocator_ = AllocatorInitialize((unsigned)sizeof(T), initialCapacity);
+            allocator_ = AllocatorInitialize((i32)sizeof(T), initialCapacity);
     }
     }
 
 
     /// Destruct.
     /// Destruct.
@@ -70,6 +84,7 @@ public:
 
 
     /// Prevent copy construction.
     /// Prevent copy construction.
     Allocator(const Allocator<T>& rhs) = delete;
     Allocator(const Allocator<T>& rhs) = delete;
+
     /// Prevent assignment.
     /// Prevent assignment.
     Allocator<T>& operator =(const Allocator<T>& rhs) = delete;
     Allocator<T>& operator =(const Allocator<T>& rhs) = delete;
 
 
@@ -77,8 +92,9 @@ public:
     T* Reserve()
     T* Reserve()
     {
     {
         if (!allocator_)
         if (!allocator_)
-            allocator_ = AllocatorInitialize((unsigned)sizeof(T));
-        auto* newObject = static_cast<T*>(AllocatorReserve(allocator_));
+            allocator_ = AllocatorInitialize((i32)sizeof(T));
+
+        T* newObject = static_cast<T*>(AllocatorReserve(allocator_));
         new(newObject) T();
         new(newObject) T();
 
 
         return newObject;
         return newObject;
@@ -88,8 +104,9 @@ public:
     T* Reserve(const T& object)
     T* Reserve(const T& object)
     {
     {
         if (!allocator_)
         if (!allocator_)
-            allocator_ = AllocatorInitialize((unsigned)sizeof(T));
-        auto* newObject = static_cast<T*>(AllocatorReserve(allocator_));
+            allocator_ = AllocatorInitialize((i32)sizeof(T));
+
+        T* newObject = static_cast<T*>(AllocatorReserve(allocator_));
         new(newObject) T(object);
         new(newObject) T(object);
 
 
         return newObject;
         return newObject;
@@ -101,10 +118,6 @@ public:
         (object)->~T();
         (object)->~T();
         AllocatorFree(allocator_, object);
         AllocatorFree(allocator_, object);
     }
     }
-
-private:
-    /// Allocator block.
-    AllocatorBlock* allocator_;
 };
 };
 
 
 }
 }

+ 2 - 2
Source/Urho3D/Container/HashMap.h

@@ -200,7 +200,7 @@ public:
     HashMap()
     HashMap()
     {
     {
         // Reserve the tail node
         // Reserve the tail node
-        allocator_ = AllocatorInitialize((unsigned)sizeof(Node));
+        allocator_ = AllocatorInitialize((i32)sizeof(Node));
         head_ = tail_ = ReserveNode();
         head_ = tail_ = ReserveNode();
     }
     }
 
 
@@ -208,7 +208,7 @@ public:
     HashMap(const HashMap<T, U>& map)
     HashMap(const HashMap<T, U>& map)
     {
     {
         // Reserve the tail node + initial capacity according to the map's size
         // Reserve the tail node + initial capacity according to the map's size
-        allocator_ = AllocatorInitialize((unsigned)sizeof(Node), map.Size() + 1);
+        allocator_ = AllocatorInitialize((i32)sizeof(Node), map.Size() + 1);
         head_ = tail_ = ReserveNode();
         head_ = tail_ = ReserveNode();
         *this = map;
         *this = map;
     }
     }

+ 2 - 2
Source/Urho3D/Container/HashSet.h

@@ -157,7 +157,7 @@ public:
     HashSet()
     HashSet()
     {
     {
         // Reserve the tail node
         // Reserve the tail node
-        allocator_ = AllocatorInitialize((unsigned)sizeof(Node));
+        allocator_ = AllocatorInitialize((i32)sizeof(Node));
         head_ = tail_ = ReserveNode();
         head_ = tail_ = ReserveNode();
     }
     }
 
 
@@ -165,7 +165,7 @@ public:
     HashSet(const HashSet<T>& set)
     HashSet(const HashSet<T>& set)
     {
     {
         // Reserve the tail node + initial capacity according to the set's size
         // Reserve the tail node + initial capacity according to the set's size
-        allocator_ = AllocatorInitialize((unsigned)sizeof(Node), set.Size() + 1);
+        allocator_ = AllocatorInitialize((i32)sizeof(Node), set.Size() + 1);
         head_ = tail_ = ReserveNode();
         head_ = tail_ = ReserveNode();
         *this = set;
         *this = set;
     }
     }

+ 2 - 2
Source/Urho3D/Container/List.h

@@ -149,7 +149,7 @@ public:
     /// Construct empty.
     /// Construct empty.
     List()
     List()
     {
     {
-        allocator_ = AllocatorInitialize((unsigned)sizeof(Node));
+        allocator_ = AllocatorInitialize((i32)sizeof(Node));
         head_ = tail_ = ReserveNode();
         head_ = tail_ = ReserveNode();
     }
     }
 
 
@@ -157,7 +157,7 @@ public:
     List(const List<T>& list)
     List(const List<T>& list)
     {
     {
         // Reserve the tail node + initial capacity according to the list's size
         // Reserve the tail node + initial capacity according to the list's size
-        allocator_ = AllocatorInitialize((unsigned)sizeof(Node), list.Size() + 1);
+        allocator_ = AllocatorInitialize((i32)sizeof(Node), list.Size() + 1);
         head_ = tail_ = ReserveNode();
         head_ = tail_ = ReserveNode();
         *this = list;
         *this = list;
     }
     }