libgit2/libgit2 — pull request #642 by arrbee (2012-04-25 18:32:00+00:00)
Title: Memory pools and khash hashtables

This PR changes a bunch of internal code related to data handling, but does not change public APIs.

* Adds a new object `git_pool` which is a paged memory allocator
* Converts attrs and diffs to use `git_pool` allocator for strings
* Converts revwalk to use `git_pool` for its lightweight commit objects
* Imports new hashtable implementation from https://github.com/attractivechaos/klib
* Adds two wrappers for khash tables - `git_khash_str` and `git_khash_oid`
* Converts all usage of `git_hashtable` to khash tables

The net effect of these changes is that we should be more memory efficient for small allocations in a number of cases, plus some of the issues with the cuckoo hashing in `git_hashtable` should go away (e.g. before the khash change, I could not successfully revwalk the core git repo).

**A note on `git_pool` usage:** It is most appropriate to use pool allocation only when you do not have to free individual objects and want to bulk free everything when you are done. So, for example, all of the small strings that result from loading in a `.gitattrbutes` file or all of the lightweight commit objects that must be kept in memory during a revwalk are good scenarios.