Re: basic_string ref across dlls

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Graeme (gprenz_at_hotmail.com)
Date: 03/06/04


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



Relevant Pages

  • Re: basic_string ref across dlls
    ... Is it possible to code forward a custom allocator so all stl classes would use it by default? ... > by all the containers in STL so we do not worry about this DLL problems? ... RTL or it could use HeapAlloc. ...
    (microsoft.public.vc.stl)
  • Re: basic_string ref across dlls
    ... You can't change the default allocator used by STL classes other than by ... >> by all the containers in STL so we do not worry about this DLL problems? ... > RTL or it could use HeapAlloc. ...
    (microsoft.public.vc.stl)
  • Re: simple dll/lib question
    ... It uses STL internally. ... but it all depends on the compiler settings. ... DLL with managed extensions turned on. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Bug in STL VS2005 / Release Lib in Debug EXE -> Buffer overrun
    ... D.h. alle Einstellungen und Compiler Version muss identisch sein. ... Das kann man bei einer DLL aber nicht garantieren, ... Aber selbst wenn Du die DLL Version der CRT verwendest muss nur ein Servicepack des Compilers oder der STL kommen und Deine STL Übergabe klappt nicht mehr. ... Die Debug und die Release images sind eben unterschieldich. ...
    (microsoft.public.de.vc)
  • Dlls under WinCE 5.0
    ... I am trying to write a DLL under WindowsCE 5.0. ... I am trying to use STL classes like vector, map, etc. ... STL map reference from my main application to my dll. ...
    (microsoft.public.windowsce.embedded.vc)