473,326 Members | 2,148 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

attaching an STL Allocator interface

I'm working with a system which has its own memory manager. Any class
which uses the system defines operator new and operator delete in the
following way:

void* operator new(size_t size) {return(memMgr.allocate(size));}
void operator delete(void *p) {memMgr.free(p);}

Here memMgr is some global object which does all the behind-the-scenes
work, taking care of things like memory pools, disk swapping certain
objects, etc.

What I'd like to do is make STL classes use this same underlying memory
manager. If I understand things right, this means I need to basically
build an Allocator which will call these memMgr.allocate and memMgr.free
fcns. (Unbelievably, nobody using this system uses STL classes so this
issue has never previously arisen.)

I'm looking for suggestions on where to find sample code implementing
STL allocators and also any general advice on undertaking this,
especially if there are any critical issues that make this idea
impossible. My naive feeling is that this shouldn't be very hard, since
the Allocator doesn't really do much except forward a couple calls, and
yet having never written an Allocator I'm a little overwhelemed by the
details in TC++PL.

Thanks for your help,
Mark
Jul 23 '05 #1
0 1051

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alex Perlov | last post by:
Let's say I have a string s; and I know exactly what allocator string s is using. Then I have separately allocated buffer char *buf = allocator<char>::allocate(buflen); which is initialized...
3
by: Orjan Westin | last post by:
Hi, I have an interesting (read frustrating) problem. I'm writing a generic container class, which holds data as well as links to other instances of itself, like this: template<class T>...
15
by: Alex Vinokur | last post by:
I am looking for any custom allocator sample code for std::vector. Thanks. -- Alex Vinokur http://mathforum.org/library/view/10978.html http://sourceforge.net/users/alexvn
3
by: Mark P | last post by:
Hi, I'm looking for some info on the default STL allocator, std::alloc. In particular, I'm wondering if it is optimized to handle many allocations of small objects. I'm thinking along the...
2
by: Joshua Kolden | last post by:
STL allocators are templates so that when you write one you are obliged to make it work with any type. However, the Intel IPP library that we use has memory aligned allocators for each of 15...
13
by: Michael B Allen | last post by:
Hi, I've tried to write the *simplest* memory allocator possible. I think it would be useful in many cases such as allocating memory on stack as a poor man's garbage collection perhaps. I was...
7
by: Grahamo | last post by:
Hi, can anybody tell me where I can get the boiler plate code for std::allocator. I need to have my version of new and delete called and want to get reference code. My compilers headers are all...
5
by: Chris Thomasson | last post by:
Does this program produce any undefined-behavior: http://pastebin.com/m5eb3c81a ?
3
by: jason.cipriani | last post by:
I'm in a rather strange situation. I have a class that does some stuff and uses a buffer to hold some data in; the details aren't important but the buffer is an std::vector: class Something {...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.