1| // Synopsis C++ Parser: fakegc.hh header file 2| // A fake garbage collector which just remembers all objects and deletes them 3| // at the end. 4| 5| // $Id: fakegc.hh,v 1.1 2002/11/17 12:11:43 chalky Exp $ 6| // 7| // This file is a part of Synopsis. 8| // Copyright (C) 2002 Stephen Davies 9| // 10| // Synopsis is free software; you can redistribute it and/or modify it 11| // under the terms of the GNU General Public License as published by 12| // the Free Software Foundation; either version 2 of the License, or 13| // (at your option) any later version. 14| // 15| // This program is distributed in the hope that it will be useful, 16| // but WITHOUT ANY WARRANTY; without even the implied warranty of 17| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18| // General Public License for more details. 19| // 20| // You should have received a copy of the GNU General Public License 21| // along with this program; if not, write to the Free Software 22| // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 23| // 02111-1307, USA. 24| 25| #ifndef H_SYNOPSIS_CPP_FAKEGC 26| #define H_SYNOPSIS_CPP_FAKEGC 27| 28| //. The fake Gargage Collector namespace 29| namespaceFakeGC 30| { 31| 32| //. Base class of objects that will be cleaned up 33| structcleanup 34| { 35| //. A pointer to the next node in the list 36| cleanup* cleanup_next; 37| 38| //. Constructor 39| cleanup(); 40| 41| //. Virtual Destructor 42| virtual ~cleanup() {} 43| }; 44| 45| //. A pointer to the head of the linked list 46| extern cleanup* head; 47| 48| //. Delete all memory blocks allocated with the GC. 49| //. *CAUTION* Make sure they are not still in use first! 50| voiddelete_all(); 51| 52| //. inline constructor for efficiency 53| inline cleanup::cleanup() 54| { 55| cleanup_next = FakeGC::head; 56| FakeGC::head = this; 57| } 58| 59| } // namespace FakeGC 60| 61| //. Bring cleanup into global NS 62| usingFakeGC::cleanup; 63| 64| #endif 65| // vim: set ts=8 sts=4 sw=4 et: