added gc_object.

git-svn-id: svn://10.0.0.236/trunk@65588 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
beard%netscape.com 2000-04-11 02:59:14 +00:00
parent 7c4cc6ee74
commit 38d43f6703
2 changed files with 24 additions and 0 deletions

View File

@ -146,6 +146,18 @@ namespace JavaScript {
static void collect() { GC_gcollect(); }
};
/**
* Generic base class for objects allocated using a gc_allocator.
*/
template <typename T> class gc_object {
public:
void* operator new(size_t) { return alloc.allocate(1, 0); }
void operator delete(void* /* ptr */) {}
private:
static gc_allocator<T> alloc;
};
template <typename T> gc_allocator<T> gc_object<T>::alloc;
}
#endif /* gc_allocator_h */

View File

@ -146,6 +146,18 @@ namespace JavaScript {
static void collect() { GC_gcollect(); }
};
/**
* Generic base class for objects allocated using a gc_allocator.
*/
template <typename T> class gc_object {
public:
void* operator new(size_t) { return alloc.allocate(1, 0); }
void operator delete(void* /* ptr */) {}
private:
static gc_allocator<T> alloc;
};
template <typename T> gc_allocator<T> gc_object<T>::alloc;
}
#endif /* gc_allocator_h */