4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "arraylist.h"
27 #include "garbage.inc"
31 // The objects inherit from GarbageObject.
32 // The constructor sets users to 1 so the caller must call
33 // Garbage::remove_user when it's done.
34 // Other users of the object must call add_user to increment the user count
35 // and Garbage::remove_user to decriment the user count.
36 // The object is only deleted if a call to Garbage::delete_object is made and
37 // the user count is 0. returns 0 when no more users, 1 if still in use.
39 // Can't make graphics elements inherit because they must be deleted
40 // when the window is locked and they change their parent pointers.
42 // Elements of link lists must first be unlinked with remove_pointer and then
43 // passed to delete_object.
45 // ArrayList objects must be deleted one at a time with delete_object.
46 // Then the pointers must be deleted with remove_all.
48 // NOTE: Garbage must be first base class or this!=0 test is broken
53 Garbage(const char *title);
56 // Called when user begins to use the object.
74 // // Called by GarbageObject constructor
75 // // void add_object(GarbageObject *ptr);
77 // // Called by user to delete the object.
78 // // Flags the object for deletion as soon as it has no users.
79 // static void delete_object(GarbageObject *ptr);
82 // // Called by remove_user and delete_object
83 // // static void remove_expired();
85 // // ArrayList<GarbageObject*> objects;
87 // // Global garbage collector
88 // static Garbage *garbage;