From: Eric Bollengier Date: Mon, 8 Mar 2010 13:09:21 +0000 (+0100) Subject: Fix #1511 when trying to insert more than 50.000 directories in bvfs X-Git-Tag: Release-5.2.1~1620 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b10586cfc35894ad194c5881b2f87445e00e14ca;p=bacula%2Fbacula Fix #1511 when trying to insert more than 50.000 directories in bvfs --- diff --git a/bacula/src/cats/bvfs.c b/bacula/src/cats/bvfs.c index af6495ab6b..b0951e2aa6 100644 --- a/bacula/src/cats/bvfs.c +++ b/bacula/src/cats/bvfs.c @@ -95,6 +95,9 @@ private: hlink *nodes; int nb_node; int max_node; + + alist *table_node; + htable *cache_ppathid; public: @@ -105,14 +108,17 @@ public: max_node = NITEMS; nodes = (hlink *) malloc(max_node * sizeof (hlink)); nb_node = 0; + table_node = New(alist(5, owned_by_alist)); + table_node->append(nodes); } hlink *get_hlink() { - if (nb_node >= max_node) { - max_node *= 2; - nodes = (hlink *)brealloc(nodes, sizeof(hlink) * max_node); + if (++nb_node >= max_node) { + nb_node = 0; + nodes = (hlink *)malloc(max_node * sizeof(hlink)); + table_node->append(nodes); } - return nodes + nb_node++; + return nodes + nb_node; } bool lookup(char *pathid) { @@ -128,7 +134,7 @@ public: ~pathid_cache() { cache_ppathid->destroy(); free(cache_ppathid); - free(nodes); + delete table_node; } private: pathid_cache(const pathid_cache &); /* prohibit pass by value */