From 210f77d2c32f14d2e99577fd3c9842bb19d47e50 Mon Sep 17 00:00:00 2001 From: Tuowen Zhao Date: Mon, 19 Sep 2016 21:14:58 +0000 Subject: Moved most modules into lib --- lib/omega/src/basic/Link.cc | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 lib/omega/src/basic/Link.cc (limited to 'lib/omega/src/basic/Link.cc') diff --git a/lib/omega/src/basic/Link.cc b/lib/omega/src/basic/Link.cc new file mode 100644 index 0000000..50b9441 --- /dev/null +++ b/lib/omega/src/basic/Link.cc @@ -0,0 +1,41 @@ +#include + +namespace omega { + +#if ListElementFreeList + static List_Element *_kludgy_List_Element_free_list_pointer; +// we rely on the fact that that is initialized to 0 before any +// constructor-based initialization that could call List_Element::new. + + void *kludgy_List_Element_new(size_t size) + { + void *mem; + if (size == sizeof(List_Element) && + _kludgy_List_Element_free_list_pointer) + { + List_Element *it = _kludgy_List_Element_free_list_pointer; + _kludgy_List_Element_free_list_pointer = it->tail; + mem = it; + } + else + mem = ::operator new(size); + + return mem; + } + + void kludgy_List_Element_delete(void *ptr, size_t size) + { + if (ptr) + if (size == sizeof(List_Element)) + { + List_Element *it = (List_Element *) ptr; + it->tail = _kludgy_List_Element_free_list_pointer; + _kludgy_List_Element_free_list_pointer = it; + } + else + ::operator delete(ptr); + } + +#endif + +} // namespace -- cgit v1.2.3-70-g09d2