Add new operator that takes an ObjectCache* and allocation flags and

template function object_cache_delete() to be used to delete objects
constructed with it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43132 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2011-11-02 21:12:09 +00:00
parent 04f0e3d37b
commit ef9d9a1720
+26
View File
@@ -68,4 +68,30 @@ void object_cache_get_usage(object_cache* cache, size_t* _allocatedMemory);
}
#endif
#ifdef __cplusplus
#include <new>
inline void*
operator new(size_t size, ObjectCache* objectCache, uint32 flags) throw()
{
return object_cache_alloc(objectCache, flags);
}
template<typename Type>
inline void
object_cache_delete(ObjectCache* objectCache, Type* object, uint32 flags = 0)
{
if (object != NULL) {
object->~Type();
object_cache_free(objectCache, object, flags);
}
}
#endif // __cplusplus
#endif /* _SLAB_SLAB_H_ */