On 2013-10-24 19:54:41 +0000, Andrei Alexandrescu <seewebsiteforem...@erdani.org> said:

Please destroy! I've literally sweat as I'm sending this :o).

Seems good. Although I'm no expert on allocators I find it very easy to grasp. One remark though.

While it generally makes sense that you know the size of an allocation when you want to deallocate, in some case it might be suboptimal to have to provide the size. For instance, you could use an allocator to allocate an object (with a virtual table and all). When comes the time to deallocate, to get the size you might have to dereference two pointers to extract the value from the classinfo, then create the proper void[] range to feed deallocate(). If your allocator is a wrapper for malloc/free, the size bit is ignored when calling free and all that work for retrieving the actual size of the object is wasted.

I don't know if this is something worth addressing.

--
Michel Fortin
michel.for...@michelf.ca
http://michelf.ca

Reply via email to