Re: basic_string ref across dlls
From: Graeme (gprenz_at_hotmail.com)
Date: 03/06/04
- Next message: Graeme: "Re: basic_string ref across dlls"
- Previous message: thePoet: "Re: question about CRT boundries"
- In reply to: Orhun Birsoy: "Re: basic_string ref across dlls"
- Next in thread: thePoet: "Re: basic_string ref across dlls"
- Reply: thePoet: "Re: basic_string ref across dlls"
- Reply: Mike U.: "Re: basic_string ref across dlls"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 7 Mar 2004 11:21:05 +1300
On Sat, 06 Mar 2004 07:41:41 -0700, Orhun Birsoy wrote:
> Is it possible to write an allocator to use HeapAlloc and etc, to be used
> by all the containers in STL so we do not worry about this DLL problems?
Yes, you can write your own allocator, but you have to remember to supply
it every time you use an STL class. Another way is to provide your own
versions of global operator new and delete. The default allocator used by
all STL containers and string uses the global operator new to get memory.
You could create a dll to which all calls to ::operator new and delete were
forwarded and the dll could get the memory using new/delete provided by the
RTL or it could use HeapAlloc. Presumably HeapAlloc provides the same
alignment guarantee that new does. The dll could possibly determine at
runtime where to get memory from e.g. to allow a debug RTL to be used - not
sure how this would work. If you use any pre built components you don't
have the source to, you won't be able to control which heap they use
though, since that component has already decided which RTL to use. You
might be able to wrap access to such components using yet another dll which
linked to the same RTL/memory manager as the component, if you had to.
Graeme
- Next message: Graeme: "Re: basic_string ref across dlls"
- Previous message: thePoet: "Re: question about CRT boundries"
- In reply to: Orhun Birsoy: "Re: basic_string ref across dlls"
- Next in thread: thePoet: "Re: basic_string ref across dlls"
- Reply: thePoet: "Re: basic_string ref across dlls"
- Reply: Mike U.: "Re: basic_string ref across dlls"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|