Re: [PATCHv4 10/12] notes.c: Implement simple memory pooling of leaf nodes
From: Alex Riesen <hidden>
Date: 2016-06-15 22:47:19
On Thu, Aug 27, 2009 at 03:43, Johan Herland[off-list ref] wrote:
When allocating a new memory pool, the older pool is leaked, but this is no worse than the current situation, where (pretty much) all leaf_nodes are leaked anyway.
Could you return the unused nodes back into tghe mempool? By making the pool a preallocated list, perhaps? And then it is trivial to provide a deallocation function for the mempool, which something really concerned about the memleak can call (like when or if libgit get more usable in an application context).
quoted hunk ↗ jump to hunk
@@ -95,7 +112,6 @@ static struct leaf_node *note_tree_find(struct int_node *tree, unsigned char n,/* unpack tree and resume search */ tree->a[i] = NULL; load_subtree(l, tree, n); - free(l);
free_leaf_node(l), which returns the node into mempool
quoted hunk ↗ jump to hunk
return note_tree_find(tree, n, key_sha1); } break;@@ -118,7 +134,6 @@ static struct leaf_node *note_tree_find(struct int_node *tree, unsigned char n,/* unpack tree and resume search */ tree->a[0] = NULL; load_subtree(l, tree, n); - free(l);
free_leaf_node(l);
return note_tree_find(tree, n, key_sha1); } return NULL;