From: Kern Sibbald Date: Mon, 24 Jan 2011 16:53:40 +0000 (+0100) Subject: Fix typo in buffer sizes off by factor of 10 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b57ae3d519c7c6e4d3b8302c501bfe67d9336636;p=bacula%2Fbacula Fix typo in buffer sizes off by factor of 10 --- diff --git a/bacula/src/lib/htable.c b/bacula/src/lib/htable.c index d1470db151..a42ec022d0 100644 --- a/bacula/src/lib/htable.c +++ b/bacula/src/lib/htable.c @@ -49,9 +49,12 @@ */ #include "bacula.h" - #include "htable.h" +#define PAGE_SIZE 4096 +#define MAX_PAGES 2400 +#define MAX_BUF_SIZE (MAX_PAGES * PAGE_SIZE) /* approx 10MB */ + static const int dbglvl = 500; /* =================================================================== @@ -103,10 +106,10 @@ char *htable::hash_malloc(int size) if (mem_block->rem < asize) { uint32_t mb_size; - if (total_size >= 1000000) { - mb_size = 1000000; + if (total_size >= (MAX_BUF_SIZE / 2)) { + mb_size = MAX_BUF_SIZE; } else { - mb_size = 100000; + mb_size = MAX_BUF_SIZE / 2; } malloc_big_buf(mb_size); } @@ -168,7 +171,7 @@ void htable::init(void *item, void *link, int tsize) table = (hlink **)malloc(buckets * sizeof(hlink *)); memset(table, 0, buckets * sizeof(hlink *)); #ifdef BIG_MALLOC - malloc_big_buf(1000000); /* ***FIXME*** need variable or some estimate */ + malloc_big_buf(MAX_BUF_SIZE); /* ***FIXME*** need variable or some estimate */ #endif } diff --git a/bacula/src/lib/tree.c b/bacula/src/lib/tree.c index 6d4a295dad..3dbb9629b8 100644 --- a/bacula/src/lib/tree.c +++ b/bacula/src/lib/tree.c @@ -36,6 +36,9 @@ #include "bacula.h" #include "findlib/find.h" +#define PAGE_SIZE 4096 +#define MAX_PAGES 2400 +#define MAX_BUF_SIZE (MAX_PAGES * PAGE_SIZE) /* approx 10MB */ /* Forward referenced subroutines */ static TREE_NODE *search_and_insert_tree_node(char *fname, int type, @@ -90,8 +93,8 @@ TREE_ROOT *new_tree(int count) memset(root, 0, sizeof(TREE_ROOT)); /* Assume filename + node = 40 characters average length */ size = count * (BALIGN(sizeof(TREE_NODE)) + 40); - if (count > 1000000 || size > 10000000) { - size = 10000000; + if (count > 1000000 || size > (MAX_BUF_SIZE / 2)) { + size = MAX_BUF_SIZE; } Dmsg2(400, "count=%d size=%d\n", count, size); malloc_buf(root, size); @@ -149,10 +152,10 @@ static char *tree_alloc(TREE_ROOT *root, int size) if (root->mem->rem < asize) { uint32_t mb_size; - if (root->total_size >= 1000000) { - mb_size = 1000000; + if (root->total_size >= (MAX_BUF_SIZE / 2)) { + mb_size = MAX_BUF_SIZE; } else { - mb_size = 100000; + mb_size = MAX_BUF_SIZE / 2; } malloc_buf(root, mb_size); }