Don Williamson  committed 28c7997

When looking at a callstack that contains a few nested New/Delete calls, it's easy to get a little confused (vs. the standard C++ constructor/destructor chain):
* Call constructor and destructor manually to reduce the number of function calls per New/Delete by one.

  • Participants
  • Parent commits 99cbc51
  • Branches default

Comments (0)

Files changed (2)

File inc/clutl/Objects.h

 // This is an example object management API that you can use, ignore or base your own
-// designs upon. It is required by the serialisation API in this library which would need
-// to be branched/copied should you want to use your own object management API.
+// designs upon.
 namespace clutl

File src/clReflectUtil/Objects.cpp

 // TODO: Lots of stuff happening in here that needs logging
 #include <clutl/Objects.h>
-#include <clcpp/FunctionCall.h>
 struct clutl::ObjectGroup::HashEntry
 		// Need a constructor to new and a destructor to delete at a later point
 		if (class_type->constructor == 0 || class_type->destructor == 0)
 			return 0;
+		// Allocate and call the constructor
 		object = (Object*)new char[type->size];
-		CallFunction(class_type->constructor, object);
+		typedef void (*CallFunc)(clutl::Object*);
+		CallFunc call_func = (CallFunc)class_type->constructor->address;
+		call_func(object);
 	// Construct the object and add to its object group
 		// Call the destructor and release the memory
 		const clcpp::Class* class_type = object->type->AsClass();
 		clcpp::internal::Assert(class_type->destructor != 0);
-		CallFunction(class_type->destructor, object);
+		typedef void (*CallFunc)(const clutl::Object*);
+		CallFunc call_func = (CallFunc)class_type->destructor->address;
+		call_func(object);
 		delete [] (char*)object;