summaryrefslogtreecommitdiff
path: root/src/errors.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-04-17 10:14:24 -0700
committerRussell Belfer <rb@github.com>2012-04-25 10:42:37 -0700
commit2bc8fa0227d549006a9870620ca1f2e08a0c305e (patch)
tree11239db2261a4b08a627072d89c65eb9c7e8a041 /src/errors.c
parenta7d19b975a604b2800ba428a185895241313d1f6 (diff)
downloadlibgit2-2bc8fa0227d549006a9870620ca1f2e08a0c305e.tar.gz
Implement git_pool paged memory allocator
This adds a `git_pool` object that can do simple paged memory allocation with free for the entire pool at once. Using this, you can replace many small allocations with large blocks that can then cheaply be doled out in small pieces. This is best used when you plan to free the small blocks all at once - for example, if they represent the parsed state from a file or data stream that are either all kept or all discarded. There are two real patterns of usage for `git_pools`: either for "string" allocation, where the item size is a single byte and you end up just packing the allocations in together, or for "fixed size" allocation where you are allocating a large object (e.g. a `git_oid`) and you generally just allocation single objects that can be tightly packed. Of course, you can use it for other things, but those two cases are the easiest.
Diffstat (limited to 'src/errors.c')
-rw-r--r--src/errors.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/errors.c b/src/errors.c
index aad6c4482..7a6bbd654 100644
--- a/src/errors.c
+++ b/src/errors.c
@@ -173,7 +173,7 @@ void giterr_set_str(int error_class, const char *string)
{
git_error *error = &GIT_GLOBAL->error_t;
- free(error->message);
+ git__free(error->message);
error->message = git__strdup(string);
error->klass = error_class;