[Orxonox-commit 4993] r9662 - code/branches/core6/src/libraries/core/object

landauf at orxonox.net landauf at orxonox.net
Sat Aug 24 19:04:41 CEST 2013


Author: landauf
Date: 2013-08-24 19:04:40 +0200 (Sat, 24 Aug 2013)
New Revision: 9662

Modified:
   code/branches/core6/src/libraries/core/object/Listable.cc
   code/branches/core6/src/libraries/core/object/Listable.h
Log:
use SmallObjectAllocator for ObjectListElements

Modified: code/branches/core6/src/libraries/core/object/Listable.cc
===================================================================
--- code/branches/core6/src/libraries/core/object/Listable.cc	2013-08-24 16:38:55 UTC (rev 9661)
+++ code/branches/core6/src/libraries/core/object/Listable.cc	2013-08-24 17:04:40 UTC (rev 9662)
@@ -99,8 +99,15 @@
         this->context_ = context;
     }
 
+    /* static */ SmallObjectAllocator& Listable::getObjectListElementAllocator()
+    {
+        static SmallObjectAllocator allocator(sizeof(ObjectListElement<Listable>), 1024);
+        return allocator;
+    }
+
     /* static */ void Listable::deleteObjectListElement(ObjectListBaseElement* element)
     {
-        delete element;
+        element->~ObjectListBaseElement();
+        Listable::getObjectListElementAllocator().free(element);
     }
 }

Modified: code/branches/core6/src/libraries/core/object/Listable.h
===================================================================
--- code/branches/core6/src/libraries/core/object/Listable.h	2013-08-24 16:38:55 UTC (rev 9661)
+++ code/branches/core6/src/libraries/core/object/Listable.h	2013-08-24 17:04:40 UTC (rev 9662)
@@ -62,10 +62,13 @@
                 { return this->context_; }
 
         private:
+            static SmallObjectAllocator& getObjectListElementAllocator();
+
             template <class T>
             static ObjectListElement<T>* createObjectListElement(T* object)
             {
-                return new ObjectListElement<T>(object);
+                void* chunk = Listable::getObjectListElementAllocator().alloc();
+                return new (chunk) ObjectListElement<T>(object);
             }
 
             static void deleteObjectListElement(ObjectListBaseElement* element);




More information about the Orxonox-commit mailing list