home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!mcsun!sunic!ericom!falcon!jonas
- From: jonas@beppe.ericsson.se (Jonas Nygren)
- Subject: How to detect dynamic allocated memory
- Message-ID: <1992Jul22.072702.4263@ericsson.se>
- Followup-To: comp.lang.c++
- Sender: news@ericsson.se
- Nntp-Posting-Host: falcon.ericsson.se
- Reply-To: jonas@beppe.ericsson.se
- Organization: Ericsson Telecom AB
- Date: Wed, 22 Jul 1992 07:27:02 GMT
- Lines: 24
-
-
- I am trying to implement a simple reference counting/smart pointer scheme
- and would like to be able to use these smart references for both automatic
- and dynamically allocated instances. To do this I need to be able to identify
- wether the instance was allocated via new or not.
-
- Is there a safe way to do this? I would like to do something similar
- to the following in the top base class' constructor:
-
- if(allocated_via_new)
- new_allocation = TRUE;
-
- The solution I am using currently is a signalling scheme via a static
- variable which is set to TRUE in my overriden new and then reset
- TO FALSE by the constructor after noting wether allocation was done via
- new or not.
-
- Is there a better way to do this??
-
- Best regards
-
- /jonas
-
-
-