aboutsummaryrefslogtreecommitdiffstats
path: root/src/defalloc.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-09-11 00:44:28 +0000
committerlloyd <[email protected]>2006-09-11 00:44:28 +0000
commit31170c2210d98c2ea8f3fac56ff5f31e27f741af (patch)
treeb43349234dfb36ae0b6e3ea97923e7f5f52eb06e /src/defalloc.cpp
parenta563159b999eea2fee0ea94d0baaea06df0ca1df (diff)
Correctly deal with allocators added post-initialization. In particular,
handle the case where an allocator is added that has the same name as one already registered. Flush the cached allocator pointer when the default is changed. Mark comparison operations in Pooling_Allocator::Memory_Block as inline; this seems to help the STL sort and binary search algorithms tremendously.
Diffstat (limited to 'src/defalloc.cpp')
-rw-r--r--src/defalloc.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/defalloc.cpp b/src/defalloc.cpp
index ad54fb3ca..5b61e7fac 100644
--- a/src/defalloc.cpp
+++ b/src/defalloc.cpp
@@ -4,6 +4,7 @@
*************************************************/
#include <botan/defalloc.h>
+#include <botan/libstate.h>
#include <botan/util.h>
#include <cstdlib>
#include <cstring>
@@ -78,4 +79,20 @@ void Locking_Allocator::dealloc_block(void* ptr, u32bit n)
do_free(ptr, n, true);
}
+/*************************************************
+* Get an allocator *
+*************************************************/
+Allocator* Allocator::get(bool locking)
+ {
+ std::string type = "";
+ if(!locking)
+ type = "malloc";
+
+ Allocator* alloc = global_state().get_allocator(type);
+ if(alloc)
+ return alloc;
+
+ throw Exception("Couldn't find an allocator to use in get_allocator");
+ }
+
}