allocator

C++ allocator<X>::deallocate(NULL,1) allowed?

Both free(NULL) and ::operator delete(NULL) are allowed. Does the allocator concept (e.g. std::allocator also allow deallocate(NULL,1), or is it required to put your own guard around it? ...

checking for failed new

why does this ATL/COM code check for successful alloc? I would have expected a custom allocation to be visible through CoGetALloc or some such api. A standards-conforming C++ runtime should be throwing std::bad_alloc, but then again maybe the allocator has indeed been traded out for a non-throwing impl. DDClientData* pNewData = new DDCl...

How can I make an object construct itself at a particular location in memory?

Possible Duplicate: Create new C++ object at specific memory address? I am writing what is essentially an object pool allocator, which will allocate a single class. I am allocating just enough memory to fit the objects that I need, and I am passing out pointers to spaces inside. Now my question is this: Once I have gotten a ...

Setting a custom allocator for strings

I know I can set a custom allocator for vectors using the syntax vector<T, Alloc>. Is there a way I can do the same for strings? ...

How to replace allocators of stl with actual source code

Hello, I need to replace allocators with their original source code. I am extracting exported methods from PE export table and facing strange lengthy allocators where STL containers were used in original source code . for example if source code was typedef std::list<std::basic_string<_TCHAR> > TokenList; EXPORTS_API const TokenL...

Reference Counted Objects and multiple Allocators

Hi Guys. This is a design question, assuming C++ and a reference counted object hierarchy. A lot of classes in my codebase derive from a common base class (ObjectBase), which implements retain() and release() methods to increase and decrease the reference count of an object instance. Every instance of an object may be created on the st...

Custom allocator for std::vector<> with release?

I am working with a 3rd party C API set in C++ that has two methods of concern for this discussion: It's equivalent of malloc(): the_api_malloc(size) (plus a matching the_api_free()) A function in which memory created with the_api_malloc() is returned to that takes ownership of it and the_api_free()'s it internally: the_api_give_back(p...