diff options
author | Tuowen Zhao <ztuowen@gmail.com> | 2016-09-17 03:22:53 +0000 |
---|---|---|
committer | Tuowen Zhao <ztuowen@gmail.com> | 2016-09-17 03:22:53 +0000 |
commit | 75ff98e4d65862ff5b36b533b4f6e3ea71ede1d5 (patch) | |
tree | 498ac06b4cf78568b807fafd2619856afff69c28 /omegalib/basic/src/Link.cc | |
parent | 29efa7b1a0d089e02a70f73f348f11878955287c (diff) | |
download | chill-75ff98e4d65862ff5b36b533b4f6e3ea71ede1d5.tar.gz chill-75ff98e4d65862ff5b36b533b4f6e3ea71ede1d5.tar.bz2 chill-75ff98e4d65862ff5b36b533b4f6e3ea71ede1d5.zip |
cmake build
Diffstat (limited to 'omegalib/basic/src/Link.cc')
-rw-r--r-- | omegalib/basic/src/Link.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/omegalib/basic/src/Link.cc b/omegalib/basic/src/Link.cc new file mode 100644 index 0000000..50b9441 --- /dev/null +++ b/omegalib/basic/src/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 |