problem about allocator-Collection of common programming errors
Dustin Getz
com atl new-operator allocator
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 DDClientData(); if (pNewData==NULL)return E_OUTOFMEMORY;
myWallJSON
c++ windows stl memory-allocation allocator
What I wonder about is simple – if we create a DLL, compile it with static runtime, while in its code we will create a simple allocator that inherits from std::allocator, would it be possible for us to Having N difrent heaps use only this library heap (one with allocator) for memory management across all N heaps? And how to create such allocator?
Alok Save
c++ memory-management stl allocator
What is the difference between memory allocation through new/malloc and allocator? Why would we ever need a separate memory allocator for vector if we have the options of new and malloc?
Qubeuc
c++ templates boost interprocess allocator
In my new project i am building a data management module.I want to give a simple template storage type to upper layers like template<typename T> class Data {public:T getValue();private:boost::numeric::ublas::matrix<T> data; }My aim is, to change allocator of data with some different allocators like Boost.inter process allocator or Boost.pool allocator (Boost Ublas Matrix and vector classes takes allocator as a template parameter ).And give only a single class and Factory method to cr
302Found
c++ unit-testing coredump allocator gmock
I have a test case which verifies the Allocator functionality of a certain class. I have Mocked few dependent interfaces, which provide me the allocator used for allocation, and also I’m mocking the malloc, realloc and free methods of the allocator. At the end of the testcase GMOCK is crashing which this dump. I couldn’t make out anything out of it. Can anybody please help… :)#0 0x0041bb7f in testing::internal::linked_ptr<testing::MatcherInterface<std::tr1::tuple<> const&>
Mooing Duck
c++ std allocator library-design
For example, why doesn’t template< typename Elem, typename Traits, typename Alloc > basic_string { … } provide:template< typename OtherAlloc > basic_string( const basic_string< Elem, Traits, OtherAlloc >& a_Other ) { … }It would seem fairly trivial to implement such a conversion constructor which respects both allocators. The current state of affair makes it very cumbersome to interface between types just differing in allocators.
Mehrdad
c++ c++11 allocator stateful
I’m writing a container and would like to permit the user to use custom allocators, but I can’t tell if I should pass allocators around by reference or by value.Is it guaranteed (or at least, a reasonable assumption to make) that an allocator object will not contain its memory pool directly, and hence it would be OK to copy an allocator and expect the memory pools of the allocators to be cross-compatible? Or do I always need to pass allocators by reference? (I have found that passing by referen
pic11
c++ allocator
Is OK to throw an exception when 0 is passed to allocate method?Thank you.P.S.If n == 0, the return value isunspecified.Does it mean that allocate shouldn’t throw an exception? I am inclined to think that if throwing wasn’t allowed for n==0, then the standard would clearly spell it out.
quant_dev
c++ boost map function-pointers allocator
Is this a Boost bug or am I doing something wrong?#include <map> #include <boost/pool/pool_alloc.hpp>int main() {typedef const std::string key;typedef double* (*value)(const int&);std::map<key, value, std::less<key>> map_with_standard_allocator; // worksstd::map<key, value, std::less<key>, boost::fast_pool_allocator<std::pair<const key, value> > > map_with_boost_allocator; // fails }the last line fails to compile under MS Visual Studio 2008 wit
Kerrek SB
c++ vector realloc allocator
A different question inspired the following thought:Does std::vector<T> have to move all the elements when it increases its capacity?As far as I understand, the standard behaviour is for the underlying allocator to request an entire chunk of the new size, then move all the old elements over, then destroy the old elements and then deallocate the old memory.This behaviour appears to be the only possible correct solution given the standard allocator interface. But I was wondering, would it ma
Filipp
c++ stl allocator
What does it mean for an allocator to be stateless? I realize that std::allocator is a wrapper around malloc, and has no state of its own. At the same time, malloc does its own bookkeeping, so one could say that all std::allocator instances make use of a single state.How would I go about implementing a pool allocator without state? If not the allocator, what would keep the current state of memory?Could someone formally define what state means in this context?
ybungalobill
c++ stl stack allocator alloca
I have two questions:1) Is it possible to implement an allocator that uses alloca to allocate memory on the stack and is otherwise C++ STL compliant?If there is code out there, you can make me happy by simply pointing me to the URL. 🙂 If there is no code out there, perhaps you can sketch the functions allocate and deallocate?2) If the answer to the above question is ‘yes’, I’d like to understand how it is possible to allocate memory on the stack for class members. As an example, consider anstd
aiao
c++ stdvector allocator
#include <iostream> #include <vector>int main() {std::vector<double> test1(1);test1[100] = 5.;std::vector< std::vector <double > > test2(1, std::vector<double>(1,0));test2[50][100] = 5.; }test1 : resizes and allocates memory nicelytest2 :”Segmentation fault (core dumped)”. Why?Note: Cannot use matrix, since row size are unequal.Summary: at(int): checks bounds and throws exception if necessary – no resizingoperator[](int) :doesnot check bounds – no resizingpush
Motti
c++ std allocator
20.6.9:void deallocate(pointer p, size_type n);Requires: p shall be a pointer value obtained from allocate(). n shall equal the value passed as the first argument to the invocation of allocate which returned p. Effects: Deallocates the storage referenced by p. Remarks: Uses ::operator delete(void*) (18.6.1), but it is unspecified when this function is called.What should happen if ndoesn’t equal the value passed as the first agrgument to the invocation of allocate which returned p? Not deallocate
Daniel Fischer
c linux malloc undefined-behavior allocator
Please tell me the difference between stack and heap with respect to below codeint main() {int arr[3];int *a;arr [5] = 6; // out of bound but it will not give error.arr [3000] = 8 ; //SIGSEGV a = malloc (sizeof (int));a[4] = 6; a[4000] = 8; //No error }I know that arr is a static array and I am accessing some other process’s address when I do arr[3000] which gives SIGSEGV error. But I don’t understand why a[4000] will not give me any run time error i.e., SIGSEGV signal.Thanks
taocp
c++ compiler-errors gtkmm allocator
I am writing a snakes and ladders game and I defined a function called draw_snake as follows:void draw_snake(const Cairo::RefPtr<Cairo::Context>& cr, std::pair<int,int> snake, std::vector< std::pair<int,int> > boardcoords);When I make the call to this function I do it as follows:pair<int, int> snake = make_pair(100,1); draw_snake(cr, snake, boardcoords);boardcoords is a vector of pair<int,int>. The error message is saying that I have a fourth parameter whe
Web site is in building