From 3286c408eccb18c525ca123383f3ebf5097441bc Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Fri, 28 Oct 2011 14:51:13 -0700 Subject: global: Properly use `git__` memory wrappers Ensure that all memory related functions (malloc, calloc, strdup, free, etc) are using their respective `git__` wrappers. --- src/pack.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/pack.c') diff --git a/src/pack.c b/src/pack.c index 2516bea93..429bb5e0f 100644 --- a/src/pack.c +++ b/src/pack.c @@ -181,7 +181,7 @@ static int pack_index_open(struct git_pack_file *p) strcpy(idx_name + strlen(idx_name) - strlen(".pack"), ".idx"); error = pack_index_check(idx_name, p); - free(idx_name); + git__free(idx_name); return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to open index"); } @@ -297,7 +297,7 @@ static int packfile_unpack_delta( error = packfile_unpack_compressed(&delta, p, w_curs, curpos, delta_size, delta_type); if (error < GIT_SUCCESS) { - free(base.data); + git__free(base.data); return git__rethrow(error, "Corrupted delta"); } @@ -306,8 +306,8 @@ static int packfile_unpack_delta( base.data, base.len, delta.data, delta.len); - free(base.data); - free(delta.data); + git__free(base.data); + git__free(delta.data); /* TODO: we might want to cache this shit. eventually */ //add_delta_base_cache(p, base_offset, base, base_size, *type); @@ -390,7 +390,7 @@ int packfile_unpack_compressed( st = inflateInit(&stream); if (st != Z_OK) { - free(buffer); + git__free(buffer); return git__throw(GIT_EZLIB, "Error in zlib"); } @@ -408,7 +408,7 @@ int packfile_unpack_compressed( inflateEnd(&stream); if ((st != Z_STREAM_END) || stream.total_out != size) { - free(buffer); + git__free(buffer); return git__throw(GIT_EZLIB, "Error in zlib"); } @@ -504,8 +504,8 @@ void packfile_free(struct git_pack_file *p) pack_index_free(p); - free(p->bad_object_sha1); - free(p); + git__free(p->bad_object_sha1); + git__free(p); } static int packfile_open(struct git_pack_file *p) @@ -598,7 +598,7 @@ int git_packfile_check(struct git_pack_file **pack_out, const char *path) */ path_len -= strlen(".idx"); if (path_len < 1) { - free(p); + git__free(p); return git__throw(GIT_ENOTFOUND, "Failed to check packfile. Wrong path name"); } @@ -610,7 +610,7 @@ int git_packfile_check(struct git_pack_file **pack_out, const char *path) strcpy(p->pack_name + path_len, ".pack"); if (p_stat(p->pack_name, &st) < GIT_SUCCESS || !S_ISREG(st.st_mode)) { - free(p); + git__free(p); return git__throw(GIT_ENOTFOUND, "Failed to check packfile. File not found"); } -- cgit v1.2.1 From a15c550db8b0552902e58c9bf2194005fb7fb0e9 Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Wed, 16 Nov 2011 14:09:44 +0100 Subject: threads: Fix the shared global state with TLS See `global.c` for a description of what we're doing. When libgit2 is built with GIT_THREADS support, the threading system must be explicitly initialized with `git_threads_init()`. --- src/pack.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/pack.c') diff --git a/src/pack.c b/src/pack.c index 429bb5e0f..ae954b988 100644 --- a/src/pack.c +++ b/src/pack.c @@ -5,11 +5,13 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "mwindow.h" +#include "common.h" #include "odb.h" #include "pack.h" #include "delta-apply.h" #include "sha1_lookup.h" +#include "mwindow.h" +#include "fileops.h" #include "git2/oid.h" #include "git2/zlib.h" -- cgit v1.2.1