====== SpeedTree New and Delete ====== Since overriding global new and delete is not a viable option for a library (these function are free to be overridden by the application if desired), a set of allocator functions were created for use by SpeedTree-associated code that would properly redirect the allocations through SpeedTree's allocator interface. These functions should only be used when: * The application is using the SpeedTree allocator interface. * The application developer has deemed it useful for the dynamic allocation to be classified together with the rest of the SpeedTree memory, as may be done when writing custom wrapper code. Note that these functions are not expected to be widely used and are by no means a requirement for SpeedTree integration. There are four functions, duplicating the functionality of new, new[], delete, and delete[]. Prototypes and example usages for each follow: // operator new equivalent (must be paired with st_delete()) #define st_new(TYPE, pDescription) new (st_allocate(pDescription)) TYPE // example usage if object constructor takes no parameters CMyObject* pObject = st_new(CMyObject, "description here"); // example usage if object constructor takes two parameters CMyObject* pObject = st_new(CMyObject, "description here")(constr_param1, constr_param2); // operator new[] equivalent (must be paired with st_delete_array()) template inline TYPE* st_new_array(size_t sNumElements, const char* pDescription); // example usage CMyObject* pObjects = st_new_array(10, "description here"); // operator delete equivalent (must be paired with placement new declared above) template inline void st_delete(TYPE*& pBlock, const char* pDescription); // example usage CMyObject* pObject = new ("description here") CMyObject; st_delete(pObject); // operator delete[] equivalent (must be paired with st_new_array()) template inline void st_delete_array(TYPE*& pRawBlock, const char* pDescription); // example usage CMyObject* pObjects = st_new_array(10, "description here"); st_delete_array(pObjects); |^**Note:** The delete functions will automatically set the pointers passed in to NULL.^|