source: abuse/trunk/src/lisp/lisp_gc.h @ 494

Last change on this file since 494 was 494, checked in by Sam Hocevar, 10 years ago

style: remove trailing spaces, fix copyright statements.

  • Property svn:keywords set to Id
File size: 1.1 KB
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *  Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
5 *
6 *  This software was released into the Public Domain. As with most public
7 *  domain software, no warranty is made or implied by Crack dot Com or
8 *  Jonathan Clark.
9 */
10
11#include "stack.h"
12#ifndef __LISP_GC_HPP_
13#define __LISP_GC_HPP_
14
15extern grow_stack<void> l_user_stack;       // stack user progs can push data and have it GCed
16
17void collect_space(int which_space); // should be tmp or permenant
18
19void register_pointer(void *&addr);
20void unregister_pointer(void *&addr);
21
22// This pointer reference stack lists all pointers to temporary lisp
23// objects. This allows the pointers to be automatically modified if an
24// object allocation triggers a garbage collection.
25class PtrRef
26{
27public:
28    template<typename T> inline PtrRef(T *&ref)
29    {
30        stack.push((void **)&ref);
31    }
32
33    inline ~PtrRef()
34    {
35        stack.pop(1);
36    }
37
38    // stack of user pointers, user pointers get remapped on GC
39    static grow_stack<void *>stack;
40};
41
42#endif
43
Note: See TracBrowser for help on using the repository browser.