diff options
author | Tuowen Zhao <ztuowen@gmail.com> | 2016-09-19 21:14:58 +0000 |
---|---|---|
committer | Tuowen Zhao <ztuowen@gmail.com> | 2016-09-19 21:14:58 +0000 |
commit | 210f77d2c32f14d2e99577fd3c9842bb19d47e50 (patch) | |
tree | 5edb327c919b8309e301c3440fb6668a0075c8ef /lib/omega/src/basic/Link.cc | |
parent | a66ce5cd670c4d3c0dc449720f5bc45dd4c281b8 (diff) | |
download | chill-210f77d2c32f14d2e99577fd3c9842bb19d47e50.tar.gz chill-210f77d2c32f14d2e99577fd3c9842bb19d47e50.tar.bz2 chill-210f77d2c32f14d2e99577fd3c9842bb19d47e50.zip |
Moved most modules into lib
Diffstat (limited to 'lib/omega/src/basic/Link.cc')
-rw-r--r-- | lib/omega/src/basic/Link.cc | 41 |
1 files changed, 41 insertions, 0 deletions
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 <basic/Link.h> + +namespace omega { + +#if ListElementFreeList + static List_Element<void*> *_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<void*>) && + _kludgy_List_Element_free_list_pointer) + { + List_Element<void*> *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<void*>)) + { + List_Element<void*> *it = (List_Element<void*> *) ptr; + it->tail = _kludgy_List_Element_free_list_pointer; + _kludgy_List_Element_free_list_pointer = it; + } + else + ::operator delete(ptr); + } + +#endif + +} // namespace |