TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: JUAN ALCOLEA
from: MATHIEU BOUCHARD
date: 1997-08-28 06:42:00
subject: Overloading NEW & DELETE: Help! :_(

 JA>   I suposse that the best approach to acomplish this is overloading the
 JA> operators new and delete. But I have a problem here: I cannot call the
 JA> "global" default new from inside my overloaded new, even using the scope
 JA> (::) operator; every attempt to call the original new results in a 
 JA> annoying
 JA> recursive call to may own overloaded new, so I can't actually allocate
 JA> memory using this approach. On the other hand, if I use malloc, the 
 JA> program
 JA> crashes. I am using DJGPP 2.1 (GCC 2.7.0, I think).
i don't know about DJGPP, but with my compiler, there is a  file
that includes the declarations for modifying the global default new.
you could hook that thing: keep the old funcptr; check the sizeof of
your object and then pass control to the old func.
matju
--- Terminate 4.00/Pro
---------------
* Origin: The Lost Remains Of SatelliteSoft BBS (1:163/215.42)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.