aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-04-12 02:46:59 +0000
committerlloyd <[email protected]>2008-04-12 02:46:59 +0000
commit21669116db5ccb075d92a24af763f7b8c7a32976 (patch)
treeafca213e9b0fd6ea87043df29c9e21074e19da03
parent04b702def2a883eada14a505955d6b369e9de88f (diff)
Make the memory allocator's chunk size a compile time constant, via a
new build.h macro BOTAN_MEM_POOL_CHUNK_SIZE
-rw-r--r--include/defalloc.h1
-rw-r--r--include/mem_pool.h4
-rw-r--r--misc/config/buildh.in1
-rw-r--r--modules/alloc_mmap/mmap_mem.h1
-rw-r--r--src/mem_pool.cpp22
-rw-r--r--src/policy.cpp1
6 files changed, 4 insertions, 26 deletions
diff --git a/include/defalloc.h b/include/defalloc.h
index 69c162ac4..6d25909ff 100644
--- a/include/defalloc.h
+++ b/include/defalloc.h
@@ -28,7 +28,6 @@ class Malloc_Allocator : public Allocator
class Locking_Allocator : public Pooling_Allocator
{
public:
- Locking_Allocator() : Pooling_Allocator(64*1024, true) {}
std::string type() const { return "locking"; }
private:
void* alloc_block(u32bit);
diff --git a/include/mem_pool.h b/include/mem_pool.h
index 9d6d8d31d..a39e88f07 100644
--- a/include/mem_pool.h
+++ b/include/mem_pool.h
@@ -25,7 +25,7 @@ class Pooling_Allocator : public Allocator
void destroy();
- Pooling_Allocator(u32bit, bool);
+ Pooling_Allocator();
~Pooling_Allocator();
private:
void get_more_core(u32bit);
@@ -61,7 +61,7 @@ class Pooling_Allocator : public Allocator
byte* buffer, *buffer_end;
};
- const u32bit PREF_SIZE;
+ static const u32bit PREF_SIZE = BOTAN_MEM_POOL_CHUNK_SIZE;
std::vector<Memory_Block> blocks;
std::vector<Memory_Block>::iterator last_used;
diff --git a/misc/config/buildh.in b/misc/config/buildh.in
index 2816eface..1976b58e9 100644
--- a/misc/config/buildh.in
+++ b/misc/config/buildh.in
@@ -12,6 +12,7 @@
#define BOTAN_MP_WORD_BITS @{var:mp_bits}
#define BOTAN_DEFAULT_BUFFER_SIZE 4096
+#define BOTAN_MEM_POOL_CHUNK_SIZE 64*1024
#define BOTAN_KARAT_MUL_THRESHOLD 12
#define BOTAN_KARAT_SQR_THRESHOLD 12
diff --git a/modules/alloc_mmap/mmap_mem.h b/modules/alloc_mmap/mmap_mem.h
index 315f55b2e..ddf999014 100644
--- a/modules/alloc_mmap/mmap_mem.h
+++ b/modules/alloc_mmap/mmap_mem.h
@@ -16,7 +16,6 @@ namespace Botan {
class MemoryMapping_Allocator : public Pooling_Allocator
{
public:
- MemoryMapping_Allocator() : Pooling_Allocator(64*1024, false) {}
std::string type() const { return "mmap"; }
private:
void* alloc_block(u32bit);
diff --git a/src/mem_pool.cpp b/src/mem_pool.cpp
index df4237106..7ab121ffb 100644
--- a/src/mem_pool.cpp
+++ b/src/mem_pool.cpp
@@ -13,25 +13,6 @@
namespace Botan {
-namespace {
-
-/*************************************************
-* Decide how much memory to allocate at once *
-*************************************************/
-u32bit choose_pref_size(u32bit provided)
- {
- if(provided)
- return provided;
-
- u32bit result = global_config().option_as_u32bit("base/memory_chunk");
- if(result)
- return result;
-
- return 16*1024;
- }
-
-}
-
/*************************************************
* Memory_Block Constructor *
*************************************************/
@@ -113,8 +94,7 @@ void Pooling_Allocator::Memory_Block::free(void* ptr, u32bit blocks) throw()
/*************************************************
* Pooling_Allocator Constructor *
*************************************************/
-Pooling_Allocator::Pooling_Allocator(u32bit p_size, bool) :
- PREF_SIZE(choose_pref_size(p_size))
+Pooling_Allocator::Pooling_Allocator()
{
mutex = global_state().get_mutex();
last_used = blocks.begin();
diff --git a/src/policy.cpp b/src/policy.cpp
index 1c4eaa7c1..f58e1ba99 100644
--- a/src/policy.cpp
+++ b/src/policy.cpp
@@ -212,7 +212,6 @@ void set_default_aliases(Config& config)
*************************************************/
void set_default_config(Config& config)
{
- config.set_option("base/memory_chunk", "64*1024");
config.set_option("base/pkcs8_tries", "3");
config.set_option("base/default_pbe",
"PBE-PKCS5v20(SHA-1,TripleDES/CBC)");