Thread: sts::allocator::allocate <memory>

  1. #1
    Registered User
    Join Date
    May 2010

    sts::allocator::allocate <memory>

    When specifying an amount or size_type to the allocate member of the std::allocator, how does that value translate to :perator new with respect to the number of bytes requested?

    Is it like malloc()?

  2. #2
    Registered User
    Join Date
    Jun 2005
    Just as with malloc(), the amount of memory to be allocated is determined as n*size, where n is the number of objects to be allocated, and size is the size of an individual object.

    The difference is, however, that a std::allocator also constructs the elements of the array (i.e. invokes constructors for class types) which malloc() and ::operator new() do not.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. std::allocator <memory>
    By Imanuel in forum C++ Programming
    Replies: 2
    Last Post: 02-08-2013, 08:05 PM
  2. Replies: 10
    Last Post: 07-10-2012, 04:28 AM
  3. Easy safe memory allocator class/functions
    By jeffcobb in forum C++ Programming
    Replies: 4
    Last Post: 05-30-2010, 02:50 AM
  4. Allocate memory inside allocated memory block?
    By Heidi_Nayak in forum C Programming
    Replies: 14
    Last Post: 04-15-2009, 04:19 PM
  5. when to allocate memory
    By SAMSAM in forum Windows Programming
    Replies: 3
    Last Post: 01-22-2003, 11:40 PM