summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/network/fetch.c2
-rw-r--r--include/git2/oid.h2
-rw-r--r--src/blob.c2
-rw-r--r--src/buffer.c2
-rw-r--r--src/cache.c2
-rw-r--r--src/commit.c10
-rw-r--r--src/config.c16
-rw-r--r--src/config_file.c64
-rw-r--r--src/delta-apply.c2
-rw-r--r--src/errors.c4
-rw-r--r--src/filebuf.c14
-rw-r--r--src/fileops.c6
-rw-r--r--src/hash.c2
-rw-r--r--src/hashtable.c10
-rw-r--r--src/index.c24
-rw-r--r--src/indexer.c10
-rw-r--r--src/mwindow.c6
-rw-r--r--src/netops.c2
-rw-r--r--src/object.c2
-rw-r--r--src/odb.c22
-rw-r--r--src/odb_loose.c16
-rw-r--r--src/odb_pack.c10
-rw-r--r--src/oid.c8
-rw-r--r--src/pack.c20
-rw-r--r--src/path.c4
-rw-r--r--src/pkt.c6
-rw-r--r--src/pqueue.c6
-rw-r--r--src/reflog.c26
-rw-r--r--src/refs.c16
-rw-r--r--src/refspec.c2
-rw-r--r--src/remote.c20
-rw-r--r--src/repository.c14
-rw-r--r--src/revwalk.c14
-rw-r--r--src/signature.c6
-rw-r--r--src/status.c10
-rw-r--r--src/tag.c10
-rw-r--r--src/transports/git.c18
-rw-r--r--src/transports/http.c20
-rw-r--r--src/transports/local.c14
-rw-r--r--src/tree-cache.c4
-rw-r--r--src/tree.c16
-rw-r--r--src/tsort.c4
-rw-r--r--src/util.c4
-rw-r--r--src/util.h2
-rw-r--r--src/vector.c4
-rw-r--r--src/win32/dir.c14
-rw-r--r--src/win32/posix.h2
-rw-r--r--src/win32/posix_w32.c44
-rw-r--r--src/win32/utf-conv.c4
-rw-r--r--tests-clay/core/path.c4
-rw-r--r--tests-clay/core/vector.c4
-rw-r--r--tests-clay/object/raw/compare.c2
-rw-r--r--tests-clay/object/raw/short.c2
-rw-r--r--tests/t00-core.c8
-rw-r--r--tests/t01-rawobj.c4
-rw-r--r--tests/t04-commit.c6
-rw-r--r--tests/t07-hashtable.c6
-rw-r--r--tests/test_helpers.c2
58 files changed, 291 insertions, 289 deletions
diff --git a/examples/network/fetch.c b/examples/network/fetch.c
index dd732f22e..35fc3eae4 100644
--- a/examples/network/fetch.c
+++ b/examples/network/fetch.c
@@ -119,7 +119,7 @@ int fetch(git_repository *repo, int argc, char **argv)
if (error < GIT_SUCCESS)
return error;
- free(packname);
+ git__free(packname);
git_indexer_free(idx);
git_remote_free(remote);
diff --git a/include/git2/oid.h b/include/git2/oid.h
index b9824b887..9cebda931 100644
--- a/include/git2/oid.h
+++ b/include/git2/oid.h
@@ -100,7 +100,7 @@ GIT_EXTERN(void) git_oid_pathfmt(char *str, const git_oid *oid);
*
* @param oid the oid structure to format
* @return the c-string; NULL if memory is exhausted. Caller must
- * deallocate the string with free().
+ * deallocate the string with git__free().
*/
GIT_EXTERN(char *) git_oid_allocfmt(const git_oid *oid);
diff --git a/src/blob.c b/src/blob.c
index 42564ab50..f13a5be15 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -27,7 +27,7 @@ size_t git_blob_rawsize(git_blob *blob)
void git_blob__free(git_blob *blob)
{
git_odb_object_close(blob->odb_object);
- free(blob);
+ git__free(blob);
}
int git_blob__parse(git_blob *blob, git_odb_object *odb_obj)
diff --git a/src/buffer.c b/src/buffer.c
index 0eeeecf2f..1fb848e46 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -97,7 +97,7 @@ const char *git_buf_cstr(git_buf *buf)
void git_buf_free(git_buf *buf)
{
- free(buf->ptr);
+ git__free(buf->ptr);
}
void git_buf_clear(git_buf *buf)
diff --git a/src/cache.c b/src/cache.c
index 79f3eaea2..6ba4d212c 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -53,7 +53,7 @@ void git_cache_free(git_cache *cache)
git_mutex_free(&cache->nodes[i].lock);
}
- free(cache->nodes);
+ git__free(cache->nodes);
}
void *git_cache_get(git_cache *cache, const git_oid *oid)
diff --git a/src/commit.c b/src/commit.c
index ced457ecc..b9eb3650f 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -32,7 +32,7 @@ static void clear_parents(git_commit *commit)
for (i = 0; i < commit->parent_oids.length; ++i) {
git_oid *parent = git_vector_get(&commit->parent_oids, i);
- free(parent);
+ git__free(parent);
}
git_vector_clear(&commit->parent_oids);
@@ -46,9 +46,9 @@ void git_commit__free(git_commit *commit)
git_signature_free(commit->author);
git_signature_free(commit->committer);
- free(commit->message);
- free(commit->message_encoding);
- free(commit);
+ git__free(commit->message);
+ git__free(commit->message_encoding);
+ git__free(commit);
}
const git_oid *git_commit_id(git_commit *c)
@@ -84,7 +84,7 @@ int git_commit_create_v(
message_encoding, message,
tree, parent_count, parents);
- free((void *)parents);
+ git__free((void *)parents);
return error;
}
diff --git a/src/config.c b/src/config.c
index ad6f88575..4e48ff7f4 100644
--- a/src/config.c
+++ b/src/config.c
@@ -35,11 +35,11 @@ void git_config_free(git_config *cfg)
internal = git_vector_get(&cfg->files, i);
file = internal->file;
file->free(file);
- free(internal);
+ git__free(internal);
}
git_vector_free(&cfg->files);
- free(cfg);
+ git__free(cfg);
}
static int config_backend_cmp(const void *a, const void *b)
@@ -61,7 +61,7 @@ int git_config_new(git_config **out)
memset(cfg, 0x0, sizeof(git_config));
if (git_vector_init(&cfg->files, 3, config_backend_cmp) < 0) {
- free(cfg);
+ git__free(cfg);
return GIT_ENOMEM;
}
@@ -125,7 +125,7 @@ int git_config_add_file(git_config *cfg, git_config_file *file, int priority)
internal->priority = priority;
if (git_vector_insert(&cfg->files, internal) < 0) {
- free(internal);
+ git__free(internal);
return GIT_ENOMEM;
}
@@ -366,20 +366,20 @@ static int win32_find_system(char *system_config_path)
return git__throw(GIT_ERROR, "Failed to expand environment strings");
if (_waccess(apphome_utf16, F_OK) < 0) {
- free(apphome_utf16);
+ git__free(apphome_utf16);
return GIT_ENOTFOUND;
}
apphome_utf8 = gitwin_from_utf16(apphome_utf16);
- free(apphome_utf16);
+ git__free(apphome_utf16);
if (strlen(apphome_utf8) >= GIT_PATH_MAX) {
- free(apphome_utf8);
+ git__free(apphome_utf8);
return git__throw(GIT_ESHORTBUFFER, "Path is too long");
}
strcpy(system_config_path, apphome_utf8);
- free(apphome_utf8);
+ git__free(apphome_utf8);
return GIT_SUCCESS;
}
#endif
diff --git a/src/config_file.c b/src/config_file.c
index 3540aae0a..3cf1bb2e2 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -90,10 +90,10 @@ static void cvar_free(cvar_t *var)
if (var == NULL)
return;
- free(var->section);
- free(var->name);
- free(var->value);
- free(var);
+ git__free(var->section);
+ git__free(var->name);
+ git__free(var->value);
+ git__free(var);
}
static void cvar_list_free(cvar_t_list *list)
@@ -188,7 +188,7 @@ static int cvar_normalize_name(cvar_t *var, char **output)
if (section_sp == NULL) {
ret = p_snprintf(name, len + 1, "%s.%s", var->section, var->name);
if (ret < 0) {
- free(name);
+ git__free(name);
return git__throw(GIT_EOSERR, "Failed to normalize name. OS err: %s", strerror(errno));
}
@@ -281,10 +281,10 @@ static void backend_free(git_config_file *_backend)
if (backend == NULL)
return;
- free(backend->file_path);
+ git__free(backend->file_path);
cvar_list_free(&backend->var_list);
- free(backend);
+ git__free(backend);
}
static int file_foreach(git_config_file *backend, int (*fn)(const char *, const char *, void *), void *data)
@@ -301,7 +301,7 @@ static int file_foreach(git_config_file *backend, int (*fn)(const char *, const
return ret;
ret = fn(normalized, var->value, data);
- free(normalized);
+ git__free(normalized);
if (ret)
break;
}
@@ -326,7 +326,7 @@ static int config_set(git_config_file *cfg, const char *name, const char *value)
if (tmp == NULL && value != NULL)
return GIT_ENOMEM;
- free(existing->value);
+ git__free(existing->value);
existing->value = tmp;
return config_write(b, existing);
@@ -411,7 +411,7 @@ int git_config_file__ondisk(git_config_file **out, const char *path)
backend->file_path = git__strdup(path);
if (backend->file_path == NULL) {
- free(backend);
+ git__free(backend);
return GIT_ENOMEM;
}
@@ -653,13 +653,13 @@ static int parse_section_header(diskfile_backend *cfg, char **section_out)
/* find the end of the variable's name */
name_end = strchr(line, ']');
if (name_end == NULL) {
- free(line);
+ git__free(line);
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse header. Can't find header name end");
}
name = (char *)git__malloc((size_t)(name_end - line) + 1);
if (name == NULL) {
- free(line);
+ git__free(line);
return GIT_ENOMEM;
}
@@ -679,8 +679,8 @@ static int parse_section_header(diskfile_backend *cfg, char **section_out)
if (isspace(c)){
name[name_length] = '\0';
error = parse_section_header_ext(line, name, section_out);
- free(line);
- free(name);
+ git__free(line);
+ git__free(name);
return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to parse header");
}
@@ -699,14 +699,14 @@ static int parse_section_header(diskfile_backend *cfg, char **section_out)
}
name[name_length] = 0;
- free(line);
+ git__free(line);
git__strtolower(name);
*section_out = name;
return GIT_SUCCESS;
error:
- free(line);
- free(name);
+ git__free(line);
+ git__free(name);
return error;
}
@@ -810,7 +810,7 @@ static int config_parse(diskfile_backend *cfg_file)
break;
case '[': /* section header, new section begins */
- free(current_section);
+ git__free(current_section);
current_section = NULL;
error = parse_section_header(cfg_file, &current_section);
break;
@@ -826,7 +826,7 @@ static int config_parse(diskfile_backend *cfg_file)
if (error < GIT_SUCCESS)
break;
- var = malloc(sizeof(cvar_t));
+ var = git__malloc(sizeof(cvar_t));
if (var == NULL) {
error = GIT_ENOMEM;
break;
@@ -837,7 +837,7 @@ static int config_parse(diskfile_backend *cfg_file)
var->section = git__strdup(current_section);
if (var->section == NULL) {
error = GIT_ENOMEM;
- free(var);
+ git__free(var);
break;
}
@@ -851,7 +851,7 @@ static int config_parse(diskfile_backend *cfg_file)
}
}
- free(current_section);
+ git__free(current_section);
return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to parse config");
}
@@ -915,7 +915,7 @@ static int config_write(diskfile_backend *cfg, cvar_t *var)
*/
pre_end = post_start = cfg->reader.read_ptr;
if (current_section)
- free(current_section);
+ git__free(current_section);
error = parse_section_header(cfg, &current_section);
if (error < GIT_SUCCESS)
break;
@@ -953,8 +953,8 @@ static int config_write(diskfile_backend *cfg, cvar_t *var)
if ((error = parse_variable(cfg, &var_name, &var_value)) == GIT_SUCCESS)
cmp = strcasecmp(var->name, var_name);
- free(var_name);
- free(var_value);
+ git__free(var_name);
+ git__free(var_value);
if (cmp != 0)
break;
@@ -1029,7 +1029,7 @@ static int config_write(diskfile_backend *cfg, cvar_t *var)
git__rethrow(error, "Failed to write new section");
cleanup:
- free(current_section);
+ git__free(current_section);
if (error < GIT_SUCCESS)
git_filebuf_cleanup(&file);
@@ -1093,7 +1093,7 @@ static int parse_multiline_variable(diskfile_backend *cfg, const char *first, ch
ret = p_snprintf(buf, len, "%s %s", first, line);
if (ret < 0) {
error = git__throw(GIT_EOSERR, "Failed to parse multiline var. Failed to put together two lines. OS err: %s", strerror(errno));
- free(buf);
+ git__free(buf);
goto out;
}
@@ -1105,14 +1105,14 @@ static int parse_multiline_variable(diskfile_backend *cfg, const char *first, ch
if (is_multiline_var(buf)) {
char *final_val;
error = parse_multiline_variable(cfg, buf, &final_val);
- free(buf);
+ git__free(buf);
buf = final_val;
}
*out = buf;
out:
- free(line);
+ git__free(line);
return error;
}
@@ -1168,14 +1168,14 @@ static int parse_variable(diskfile_backend *cfg, char **var_name, char **var_val
if (error != GIT_SUCCESS)
{
*var_value = NULL;
- free(*var_name);
+ git__free(*var_name);
}
goto out;
}
- tmp = strdup(value_start);
+ tmp = git__strdup(value_start);
if (tmp == NULL) {
- free(*var_name);
+ git__free(*var_name);
*var_value = NULL;
error = GIT_ENOMEM;
goto out;
@@ -1188,6 +1188,6 @@ static int parse_variable(diskfile_backend *cfg, char **var_name, char **var_val
}
out:
- free(line);
+ git__free(line);
return error;
}
diff --git a/src/delta-apply.c b/src/delta-apply.c
index e1fb15b9b..3e40bf8cf 100644
--- a/src/delta-apply.c
+++ b/src/delta-apply.c
@@ -109,7 +109,7 @@ int git__delta_apply(
return GIT_SUCCESS;
fail:
- free(out->data);
+ git__free(out->data);
out->data = NULL;
return git__throw(GIT_ERROR, "Failed to apply delta");
}
diff --git a/src/errors.c b/src/errors.c
index 60d774636..18afff3b5 100644
--- a/src/errors.c
+++ b/src/errors.c
@@ -70,9 +70,9 @@ void git___rethrow(const char *msg, ...)
vsnprintf(new_error, sizeof(new_error), msg, va);
va_end(va);
- old_error = strdup(g_last_error);
+ old_error = git__strdup(g_last_error);
snprintf(g_last_error, sizeof(g_last_error), "%s \n - %s", new_error, old_error);
- free(old_error);
+ git__free(old_error);
}
void git___throw(const char *msg, ...)
diff --git a/src/filebuf.c b/src/filebuf.c
index 1a98e3f43..3f57d295d 100644
--- a/src/filebuf.c
+++ b/src/filebuf.c
@@ -63,13 +63,13 @@ void git_filebuf_cleanup(git_filebuf *file)
if (file->digest)
git_hash_free_ctx(file->digest);
- free(file->buffer);
- free(file->z_buf);
+ git__free(file->buffer);
+ git__free(file->z_buf);
deflateEnd(&file->zs);
- free(file->path_original);
- free(file->path_lock);
+ git__free(file->path_original);
+ git__free(file->path_lock);
}
GIT_INLINE(int) flush_buffer(git_filebuf *file)
@@ -248,7 +248,7 @@ int git_filebuf_hash(git_oid *oid, git_filebuf *file)
int git_filebuf_commit_at(git_filebuf *file, const char *path)
{
- free(file->path_original);
+ git__free(file->path_original);
file->path_original = git__strdup(path);
if (file->path_original == NULL)
return GIT_ENOMEM;
@@ -368,12 +368,12 @@ int git_filebuf_printf(git_filebuf *file, const char *format, ...)
va_end(arglist);
if (len < 0) {
- free(tmp_buffer);
+ git__free(tmp_buffer);
return git__throw(GIT_EOSERR, "Failed to format string");
}
error = git_filebuf_write(file, tmp_buffer, len);
- free(tmp_buffer);
+ git__free(tmp_buffer);
return error;
}
diff --git a/src/fileops.c b/src/fileops.c
index 203cce0a4..c8de8d83d 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -181,7 +181,7 @@ int git_futils_readbuffer_updated(git_fbuffer *obj, const char *path, time_t *mt
if (p_read(fd, buff, len) < 0) {
p_close(fd);
- free(buff);
+ git__free(buff);
return git__throw(GIT_ERROR, "Failed to read file `%s`", path);
}
buff[len] = '\0';
@@ -207,7 +207,7 @@ int git_futils_readbuffer(git_fbuffer *obj, const char *path)
void git_futils_freebuffer(git_fbuffer *obj)
{
assert(obj);
- free(obj->data);
+ git__free(obj->data);
obj->data = NULL;
}
@@ -326,7 +326,7 @@ int git_futils_mkdir_r(const char *path, int mode)
error = GIT_SUCCESS;
}
- free(path_copy);
+ git__free(path_copy);
if (error < GIT_SUCCESS)
return git__throw(error, "Failed to recursively create `%s` tree structure", path);
diff --git a/src/hash.c b/src/hash.c
index ff85ca957..56063cc0b 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -32,7 +32,7 @@ git_hash_ctx *git_hash_new_ctx(void)
void git_hash_free_ctx(git_hash_ctx *ctx)
{
- free(ctx);
+ git__free(ctx);
}
void git_hash_init(git_hash_ctx *ctx)
diff --git a/src/hashtable.c b/src/hashtable.c
index 1382eabaa..15d173992 100644
--- a/src/hashtable.c
+++ b/src/hashtable.c
@@ -39,17 +39,17 @@ static int resize_to(git_hashtable *self, size_t new_size)
self->is_resizing = 0;
else {
new_size *= 2;
- free(self->nodes);
+ git__free(self->nodes);
}
} while(self->is_resizing);
- free(old_nodes);
+ git__free(old_nodes);
return GIT_SUCCESS;
}
static int set_size(git_hashtable *self, size_t new_size)
{
- self->nodes = realloc(self->nodes, new_size * sizeof(git_hashtable_node));
+ self->nodes = git__realloc(self->nodes, new_size * sizeof(git_hashtable_node));
if (self->nodes == NULL)
return GIT_ENOMEM;
@@ -156,8 +156,8 @@ void git_hashtable_free(git_hashtable *self)
{
assert(self);
- free(self->nodes);
- free(self);
+ git__free(self->nodes);
+ git__free(self);
}
diff --git a/src/index.c b/src/index.c
index 7bf5daf2c..9ace9515f 100644
--- a/src/index.c
+++ b/src/index.c
@@ -138,7 +138,7 @@ static int index_initialize(git_index **index_out, git_repository *owner, const
index->index_file_path = git__strdup(index_path);
if (index->index_file_path == NULL) {
- free(index);
+ git__free(index);
return GIT_ENOMEM;
}
@@ -179,8 +179,8 @@ void git_index_free(git_index *index)
git_vector_free(&index->entries);
git_vector_free(&index->unmerged);
- free(index->index_file_path);
- free(index);
+ git__free(index->index_file_path);
+ git__free(index);
}
void git_index_clear(git_index *index)
@@ -192,15 +192,15 @@ void git_index_clear(git_index *index)
for (i = 0; i < index->entries.length; ++i) {
git_index_entry *e;
e = git_vector_get(&index->entries, i);
- free(e->path);
- free(e);
+ git__free(e->path);
+ git__free(e);
}
for (i = 0; i < index->unmerged.length; ++i) {
git_index_entry_unmerged *e;
e = git_vector_get(&index->unmerged, i);
- free(e->path);
- free(e);
+ git__free(e->path);
+ git__free(e);
}
git_vector_clear(&index->entries);
@@ -334,7 +334,7 @@ static int index_entry_init(git_index_entry **entry_out, git_index *index, const
entry->flags |= (stage << GIT_IDXENTRY_STAGESHIFT);
entry->path = git__strdup(rel_path);
if (entry->path == NULL) {
- free(entry);
+ git__free(entry);
return GIT_ENOMEM;
}
@@ -364,8 +364,8 @@ static void index_entry_free(git_index_entry *entry)
{
if (!entry)
return;
- free(entry->path);
- free(entry);
+ git__free(entry->path);
+ git__free(entry);
}
static int index_insert(git_index *index, git_index_entry *entry, int replace)
@@ -416,8 +416,8 @@ static int index_insert(git_index *index, git_index_entry *entry, int replace)
/* exists, replace it */
entry_array = (git_index_entry **) index->entries.contents;
- free(entry_array[position]->path);
- free(entry_array[position]);
+ git__free(entry_array[position]->path);
+ git__free(entry_array[position]);
entry_array[position] = entry;
return GIT_SUCCESS;
diff --git a/src/indexer.c b/src/indexer.c
index d5f605fdb..a09353ab7 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -367,7 +367,7 @@ int git_indexer_run(git_indexer *idx, git_indexer_stats *stats)
idx->fanout[i]++;
}
- free(obj.data);
+ git__free(obj.data);
stats->processed = ++processed;
}
@@ -390,12 +390,12 @@ void git_indexer_free(git_indexer *idx)
p_close(idx->pack->mwf.fd);
git_vector_foreach(&idx->objects, i, e)
- free(e);
+ git__free(e);
git_vector_free(&idx->objects);
git_vector_foreach(&idx->pack->cache, i, pe)
- free(pe);
+ git__free(pe);
git_vector_free(&idx->pack->cache);
- free(idx->pack);
- free(idx);
+ git__free(idx->pack);
+ git__free(idx);
}
diff --git a/src/mwindow.c b/src/mwindow.c
index e53477e98..126268fd9 100644
--- a/src/mwindow.c
+++ b/src/mwindow.c
@@ -69,7 +69,7 @@ void git_mwindow_free_all(git_mwindow_file *mwf)
git_futils_mmap_free(&w->window_map);
mwf->windows = w->next;
- free(w);
+ git__free(w);
}
}
@@ -139,7 +139,7 @@ static int git_mwindow_close_lru(git_mwindow_file *mwf)
else
*list = lru_w->next;
- free(lru_w);
+ git__free(lru_w);
ctl.open_windows--;
return GIT_SUCCESS;
@@ -191,7 +191,7 @@ static git_mwindow *new_window(git_mwindow_file *mwf, git_file fd, git_off_t siz
return w;
cleanup:
- free(w);
+ git__free(w);
return NULL;
}
diff --git a/src/netops.c b/src/netops.c
index dad296a94..73375d725 100644
--- a/src/netops.c
+++ b/src/netops.c
@@ -190,7 +190,7 @@ int gitno_extract_host_and_port(char **host, char **port, const char *url, const
delim = colon == NULL ? slash : colon;
*host = git__strndup(url, delim - url);
if (*host == NULL) {
- free(*port);
+ git__free(*port);
error = GIT_ENOMEM;
}
diff --git a/src/object.c b/src/object.c
index edc2d80fa..c84e94b05 100644
--- a/src/object.c
+++ b/src/object.c
@@ -213,7 +213,7 @@ void git_object__free(void *_obj)
break;
default:
- free(object);
+ git__free(object);
break;
}
}
diff --git a/src/odb.c b/src/odb.c
index 60789cf70..69fdba009 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -83,8 +83,8 @@ static void free_odb_object(void *o)
git_odb_object *object = (git_odb_object *)o;
if (object != NULL) {
- free(object->raw.data);
- free(object);
+ git__free(object->raw.data);
+ git__free(object);
}
}
@@ -205,8 +205,8 @@ static void fake_wstream__free(git_odb_stream *_stream)
{
fake_wstream *stream = (fake_wstream *)_stream;
- free(stream->buffer);
- free(stream);
+ git__free(stream->buffer);
+ git__free(stream);
}
static int init_fake_wstream(git_odb_stream **stream_p, git_odb_backend *backend, size_t size, git_otype type)
@@ -221,7 +221,7 @@ static int init_fake_wstream(git_odb_stream **stream_p, git_odb_backend *backend
stream->type = type;
stream->buffer = git__malloc(size);
if (stream->buffer == NULL) {
- free(stream);
+ git__free(stream);
return GIT_ENOMEM;
}
@@ -265,12 +265,12 @@ int git_odb_new(git_odb **out)
error = git_cache_init(&db->cache, GIT_DEFAULT_CACHE_SIZE, &free_odb_object);
if (error < GIT_SUCCESS) {
- free(db);
+ git__free(db);
return git__rethrow(error, "Failed to create object database");
}
if ((error = git_vector_init(&db->backends, 4, backend_sort_cmp)) < GIT_SUCCESS) {
- free(db);
+ git__free(db);
return git__rethrow(error, "Failed to create object database");
}
@@ -296,7 +296,7 @@ static int add_backend_internal(git_odb *odb, git_odb_backend *backend, int prio
internal->is_alternate = is_alternate;
if (git_vector_insert(&odb->backends, internal) < 0) {
- free(internal);
+ git__free(internal);
return GIT_ENOMEM;
}
@@ -421,14 +421,14 @@ void git_odb_close(git_odb *db)
git_odb_backend *backend = internal->backend;
if (backend->free) backend->free(backend);
- else free(backend);
+ else git__free(backend);
- free(internal);
+ git__free(internal);
}
git_vector_free(&db->backends);
git_cache_free(&db->cache);
- free(db);
+ git__free(db);
}
int git_odb_exists(git_odb *db, const git_oid *id)
diff --git a/src/odb_loose.c b/src/odb_loose.c
index dbfe18b43..538fbc909 100644
--- a/src/odb_loose.c
+++ b/src/odb_loose.c
@@ -277,7 +277,7 @@ static void *inflate_tail(z_stream *s, void *hb, size_t used, obj_hdr *hdr)
else {
set_stream_output(s, buf + used, hdr->size - used);
if (finish_inflate(s)) {
- free(buf);
+ git__free(buf);
return NULL;
}
}
@@ -317,7 +317,7 @@ static int inflate_packlike_loose_disk_obj(git_rawobj *out, git_fbuffer *obj)
in = ((unsigned char *)obj->data) + used;
len = obj->len - used;
if (inflate_buffer(in, len, buf, hdr.size)) {
- free(buf);
+ git__free(buf);
return git__throw(GIT_ERROR, "Failed to inflate loose object. Could not inflate buffer");
}
buf[hdr.size] = '\0';
@@ -686,7 +686,7 @@ static void loose_backend__stream_free(git_odb_stream *_stream)
if (!stream->finished)
git_filebuf_cleanup(&stream->fbuf);
- free(stream);
+ git__free(stream);
}
static int format_object_header(char *hdr, size_t n, size_t obj_len, git_otype obj_type)
@@ -739,14 +739,14 @@ static int loose_backend__stream(git_odb_stream **stream_out, git_odb_backend *_
(backend->object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT));
if (error < GIT_SUCCESS) {
- free(stream);
+ git__free(stream);
return git__rethrow(error, "Failed to create loose backend stream");
}
error = stream->stream.write((git_odb_stream *)stream, hdr, hdrlen);
if (error < GIT_SUCCESS) {
git_filebuf_cleanup(&stream->fbuf);
- free(stream);
+ git__free(stream);
return git__rethrow(error, "Failed to create loose backend stream");
}
@@ -803,8 +803,8 @@ static void loose_backend__free(git_odb_backend *_backend)
assert(_backend);
backend = (loose_backend *)_backend;
- free(backend->objects_dir);
- free(backend);
+ git__free(backend->objects_dir);
+ git__free(backend);
}
int git_odb_backend_loose(
@@ -821,7 +821,7 @@ int git_odb_backend_loose(
backend->objects_dir = git__strdup(objects_dir);
if (backend->objects_dir == NULL) {
- free(backend);
+ git__free(backend);
return GIT_ENOMEM;
}
diff --git a/src/odb_pack.c b/src/odb_pack.c
index a8f854236..800e7b0da 100644
--- a/src/odb_pack.c
+++ b/src/odb_pack.c
@@ -231,7 +231,7 @@ static int packfile_load__cb(void *_data, char *path)
return git__rethrow(error, "Failed to load packfile");
if (git_vector_insert(&backend->packs, pack) < GIT_SUCCESS) {
- free(pack);
+ git__free(pack);
return GIT_ENOMEM;
}
@@ -445,8 +445,8 @@ static void pack_backend__free(git_odb_backend *_backend)
}
git_vector_free(&backend->packs);
- free(backend->pack_folder);
- free(backend);
+ git__free(backend->pack_folder);
+ git__free(backend);
}
int git_odb_backend_pack(git_odb_backend **backend_out, const char *objects_dir)
@@ -459,7 +459,7 @@ int git_odb_backend_pack(git_odb_backend **backend_out, const char *objects_dir)
return GIT_ENOMEM;
if (git_vector_init(&backend->packs, 8, packfile_sort__cb) < GIT_SUCCESS) {
- free(backend);
+ git__free(backend);
return GIT_ENOMEM;
}
@@ -469,7 +469,7 @@ int git_odb_backend_pack(git_odb_backend **backend_out, const char *objects_dir)
backend->pack_folder_mtime = 0;
if (backend->pack_folder == NULL) {
- free(backend);
+ git__free(backend);
return GIT_ENOMEM;
}
}
diff --git a/src/oid.c b/src/oid.c
index bbf19ea20..4b3080430 100644
--- a/src/oid.c
+++ b/src/oid.c
@@ -223,7 +223,7 @@ struct git_oid_shorten {
static int resize_trie(git_oid_shorten *self, size_t new_size)
{
- self->nodes = realloc(self->nodes, new_size * sizeof(trie_node));
+ self->nodes = git__realloc(self->nodes, new_size * sizeof(trie_node));
if (self->nodes == NULL)
return GIT_ENOMEM;
@@ -270,7 +270,7 @@ git_oid_shorten *git_oid_shorten_new(size_t min_length)
memset(os, 0x0, sizeof(git_oid_shorten));
if (resize_trie(os, 16) < GIT_SUCCESS) {
- free(os);
+ git__free(os);
return NULL;
}
@@ -282,8 +282,8 @@ git_oid_shorten *git_oid_shorten_new(size_t min_length)
void git_oid_shorten_free(git_oid_shorten *os)
{
- free(os->nodes);
- free(os);
+ git__free(os->nodes);
+ git__free(os);
}
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");
}
diff --git a/src/path.c b/src/path.c
index 2c6b76dd0..a8851dfdc 100644
--- a/src/path.c
+++ b/src/path.c
@@ -144,7 +144,7 @@ char *git_path_dirname(const char *path)
return NULL;
if (git_path_dirname_r(dname, len, path) < GIT_SUCCESS) {
- free(dname);
+ git__free(dname);
return NULL;
}
@@ -162,7 +162,7 @@ char *git_path_basename(const char *path)
return NULL;
if (git_path_basename_r(bname, len, path) < GIT_SUCCESS) {
- free(bname);
+ git__free(bname);
return NULL;
}
diff --git a/src/pkt.c b/src/pkt.c
index 9471df2d5..ff8c56eb2 100644
--- a/src/pkt.c
+++ b/src/pkt.c
@@ -149,7 +149,7 @@ static int ref_pkt(git_pkt **out, const char *line, size_t len)
out:
if (error < GIT_SUCCESS)
- free(pkt);
+ git__free(pkt);
else
*out = (git_pkt *)pkt;
@@ -260,10 +260,10 @@ void git_pkt_free(git_pkt *pkt)
{
if(pkt->type == GIT_PKT_REF) {
git_pkt_ref *p = (git_pkt_ref *) pkt;
- free(p->head.name);
+ git__free(p->head.name);
}
- free(pkt);
+ git__free(pkt);
}
int git_pkt_buffer_flush(git_buf *buf)
diff --git a/src/pqueue.c b/src/pqueue.c
index b5ddab835..80713fbba 100644
--- a/src/pqueue.c
+++ b/src/pqueue.c
@@ -17,7 +17,7 @@ int git_pqueue_init(git_pqueue *q, size_t n, git_pqueue_cmp cmppri)
assert(q);
/* Need to allocate n+1 elements since element 0 isn't used. */
- if ((q->d = malloc((n + 1) * sizeof(void *))) == NULL)
+ if ((q->d = git__malloc((n + 1) * sizeof(void *))) == NULL)
return GIT_ENOMEM;
q->size = 1;
@@ -30,7 +30,7 @@ int git_pqueue_init(git_pqueue *q, size_t n, git_pqueue_cmp cmppri)
void git_pqueue_free(git_pqueue *q)
{
- free(q->d);
+ git__free(q->d);
q->d = NULL;
}
@@ -102,7 +102,7 @@ int git_pqueue_insert(git_pqueue *q, void *d)
/* allocate more memory if necessary */
if (q->size >= q->avail) {
newsize = q->size + q->step;
- if ((tmp = realloc(q->d, sizeof(void *) * newsize)) == NULL)
+ if ((tmp = git__realloc(q->d, sizeof(void *) * newsize)) == NULL)
return GIT_ENOMEM;
q->d = tmp;
diff --git a/src/reflog.c b/src/reflog.c
index 594963c03..a7e1f9259 100644
--- a/src/reflog.c
+++ b/src/reflog.c
@@ -25,8 +25,8 @@ static int reflog_init(git_reflog **reflog, git_reference *ref)
log->ref_name = git__strdup(ref->name);
if (git_vector_init(&log->entries, 0, NULL) < 0) {
- free(log->ref_name);
- free(log);
+ git__free(log->ref_name);
+ git__free(log);
return GIT_ENOMEM;
}
@@ -86,8 +86,8 @@ static int reflog_parse(git_reflog *log, const char *buf, size_t buf_size)
#define seek_forward(_increase) { \
if (_increase >= buf_size) { \
if (entry->committer) \
- free(entry->committer); \
- free(entry); \
+ git__free(entry->committer); \
+ git__free(entry); \
return git__throw(GIT_ERROR, "Failed to seek forward. Buffer size exceeded"); \
} \
buf += _increase; \
@@ -101,13 +101,13 @@ static int reflog_parse(git_reflog *log, const char *buf, size_t buf_size)
entry->committer = NULL;
if (git_oid_fromstrn(&entry->oid_old, buf, GIT_OID_HEXSZ) < GIT_SUCCESS) {
- free(entry);
+ git__free(entry);
return GIT_ERROR;
}
seek_forward(GIT_OID_HEXSZ + 1);
if (git_oid_fromstrn(&entry->oid_cur, buf, GIT_OID_HEXSZ) < GIT_SUCCESS) {
- free(entry);
+ git__free(entry);
return GIT_ERROR;
}
seek_forward(GIT_OID_HEXSZ + 1);
@@ -120,13 +120,13 @@ static int reflog_parse(git_reflog *log, const char *buf, size_t buf_size)
entry->committer = git__malloc(sizeof(git_signature));
if (entry->committer == NULL) {
- free(entry);
+ git__free(entry);
return GIT_ENOMEM;
}
if ((error = git_signature__parse(entry->committer, &ptr, buf + 1, NULL, *buf)) < GIT_SUCCESS) {
- free(entry->committer);
- free(entry);
+ git__free(entry->committer);
+ git__free(entry);
return git__rethrow(error, "Failed to parse reflog. Could not parse signature");
}
@@ -164,13 +164,13 @@ void git_reflog_free(git_reflog *reflog)
git_signature_free(entry->committer);
- free(entry->msg);
- free(entry);
+ git__free(entry->msg);
+ git__free(entry);
}
git_vector_free(&reflog->entries);
- free(reflog->ref_name);
- free(reflog);
+ git__free(reflog->ref_name);
+ git__free(reflog);
}
int git_reflog_read(git_reflog **reflog, git_reference *ref)
diff --git a/src/refs.c b/src/refs.c
index fcf771b5e..f21ca69de 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -77,12 +77,12 @@ static void reference_free(git_reference *reference)
return;
if (reference->name)
- free(reference->name);
+ git__free(reference->name);
if (reference->type == GIT_REF_SYMBOLIC)
- free(((reference_symbolic *)reference)->target);
+ git__free(((reference_symbolic *)reference)->target);
- free(reference);
+ git__free(reference);
}
static int reference_create(
@@ -212,7 +212,7 @@ static int loose_parse_symbolic(git_reference *ref, git_fbuffer *file_content)
refname_start += header_len;
- free(ref_sym->target);
+ git__free(ref_sym->target);
ref_sym->target = git__strdup(refname_start);
if (ref_sym->target == NULL)
return GIT_ENOMEM;
@@ -1203,7 +1203,7 @@ int git_reference_set_oid(git_reference *ref, const git_oid *id)
ref_old->ref.name = git__strdup(ref->name);
if (ref_old->ref.name == NULL) {
- free(ref_old);
+ git__free(ref_old);
return GIT_ENOMEM;
}
}
@@ -1252,7 +1252,7 @@ int git_reference_set_target(git_reference *ref, const char *target)
ref_sym = (reference_symbolic *)ref;
- free(ref_sym->target);
+ git__free(ref_sym->target);
ref_sym->target = git__strdup(target);
if (ref_sym->target == NULL)
return GIT_ENOMEM;
@@ -1381,7 +1381,7 @@ int git_reference_rename(git_reference *ref, const char *new_name, int force)
goto rollback;
}
- free(ref->name);
+ git__free(ref->name);
ref->name = new_ref->name;
/*
@@ -1408,7 +1408,7 @@ int git_reference_rename(git_reference *ref, const char *new_name, int force)
goto rollback;
cleanup:
- free(old_name);
+ git__free(old_name);
return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to rename reference");
rollback:
diff --git a/src/refspec.c b/src/refspec.c
index ed4b5e6b8..e60e8f5b5 100644
--- a/src/refspec.c
+++ b/src/refspec.c
@@ -32,7 +32,7 @@ int git_refspec_parse(git_refspec *refspec, const char *str)
refspec->dst = git__strdup(delim + 1);
if (refspec->dst == NULL) {
- free(refspec->src);
+ git__free(refspec->src);
refspec->src = NULL;
return GIT_ENOMEM;
}
diff --git a/src/remote.c b/src/remote.c
index a557a4930..3ff08a21e 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -36,7 +36,7 @@ static int refspec_parse(git_refspec *refspec, const char *str)
refspec->dst = git__strdup(delim + 1);
if (refspec->dst == NULL) {
- free(refspec->src);
+ git__free(refspec->src);
refspec->src = NULL;
return GIT_ENOMEM;
}
@@ -68,7 +68,7 @@ int git_remote_new(git_remote **out, git_repository *repo, const char *url)
remote->repo = repo;
remote->url = git__strdup(url);
if (remote->url == NULL) {
- free(remote);
+ git__free(remote);
return GIT_ENOMEM;
}
@@ -150,7 +150,7 @@ int git_remote_get(git_remote **out, git_config *cfg, const char *name)
*out = remote;
cleanup:
- free(buf);
+ git__free(buf);
if (error < GIT_SUCCESS)
git_remote_free(remote);
@@ -260,17 +260,17 @@ void git_remote_free(git_remote *remote)
if (remote == NULL)
return;
- free(remote->fetch.src);
- free(remote->fetch.dst);
- free(remote->push.src);
- free(remote->push.dst);
- free(remote->url);
- free(remote->name);
+ git__free(remote->fetch.src);
+ git__free(remote->fetch.dst);
+ git__free(remote->push.src);
+ git__free(remote->push.dst);
+ git__free(remote->url);
+ git__free(remote->name);
if (remote->transport != NULL) {
if (remote->transport->connected)
remote->transport->close(remote->transport);
remote->transport->free(remote->transport);
}
- free(remote);
+ git__free(remote);
}
diff --git a/src/repository.c b/src/repository.c
index 328bc0d57..33a3f270b 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -168,12 +168,12 @@ static git_repository *repository_alloc(void)
error = git_cache_init(&repo->objects, GIT_DEFAULT_CACHE_SIZE, &git_object__free);
if (error < GIT_SUCCESS) {
- free(repo);
+ git__free(repo);
return NULL;
}
if (git_repository__refcache_init(&repo->references) < GIT_SUCCESS) {
- free(repo);
+ git__free(repo);
return NULL;
}
@@ -467,13 +467,13 @@ static int read_gitfile(char *path_out, const char *file_path, const char *base_
static void git_repository__free_dirs(git_repository *repo)
{
- free(repo->path_workdir);
+ git__free(repo->path_workdir);
repo->path_workdir = NULL;
- free(repo->path_index);
+ git__free(repo->path_index);
repo->path_index = NULL;
- free(repo->path_repository);
+ git__free(repo->path_repository);
repo->path_repository = NULL;
- free(repo->path_odb);
+ git__free(repo->path_odb);
repo->path_odb = NULL;
}
@@ -489,7 +489,7 @@ void git_repository_free(git_repository *repo)
if (repo->db != NULL)
git_odb_close(repo->db);
- free(repo);
+ git__free(repo);
}
int git_repository_discover(char *repository_path, size_t size, const char *start_path, int across_fs, const char *ceiling_dirs)
diff --git a/src/revwalk.c b/src/revwalk.c
index 2d70d40e9..7e31650ff 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -68,7 +68,7 @@ static void commit_list_free(commit_list **list_p)
while (list) {
commit_list *temp = list;
list = temp->next;
- free(temp);
+ git__free(temp);
}
*list_p = NULL;
@@ -81,7 +81,7 @@ static commit_object *commit_list_pop(commit_list **stack)
if (top) {
*stack = top->next;
- free(top);
+ git__free(top);
}
return item;
}
@@ -156,7 +156,7 @@ static commit_object *commit_lookup(git_revwalk *walk, const git_oid *oid)
git_oid_cpy(&commit->oid, oid);
if (git_hashtable_insert(walk->commits, &commit->oid, commit) < GIT_SUCCESS) {
- free(commit);
+ git__free(commit);
return NULL;
}
@@ -442,7 +442,7 @@ int git_revwalk_new(git_revwalk **revwalk_out, git_repository *repo)
(git_hash_keyeq_ptr)git_oid_cmp);
if (walk->commits == NULL) {
- free(walk);
+ git__free(walk);
return GIT_ENOMEM;
}
@@ -475,17 +475,17 @@ void git_revwalk_free(git_revwalk *walk)
* make sure it's being free'd */
GIT_HASHTABLE_FOREACH(walk->commits, _unused, commit, {
if (commit->out_degree > PARENTS_PER_COMMIT)
- free(commit->parents);
+ git__free(commit->parents);
});
git_hashtable_free(walk->commits);
git_pqueue_free(&walk->iterator_time);
for (i = 0; i < walk->memory_alloc.length; ++i)
- free(git_vector_get(&walk->memory_alloc, i));
+ git__free(git_vector_get(&walk->memory_alloc, i));
git_vector_free(&walk->memory_alloc);
- free(walk);
+ git__free(walk);
}
git_repository *git_revwalk_repository(git_revwalk *walk)
diff --git a/src/signature.c b/src/signature.c
index 388e8d9c9..832d6439c 100644
--- a/src/signature.c
+++ b/src/signature.c
@@ -15,9 +15,9 @@ void git_signature_free(git_signature *sig)
if (sig == NULL)
return;
- free(sig->name);
- free(sig->email);
- free(sig);
+ git__free(sig->name);
+ git__free(sig->email);
+ git__free(sig);
}
static const char *skip_leading_spaces(const char *buffer, const char *buffer_end)
diff --git a/src/status.c b/src/status.c
index c53c4acc9..1fc3794ea 100644
--- a/src/status.c
+++ b/src/status.c
@@ -229,7 +229,7 @@ static int store_if_changed(struct status_st *st, struct status_entry *e)
return git__throw(error, "Failed to process the file '%s'. It doesn't exist in the workdir, in the HEAD nor in the index", e->path);
if (e->status_flags == GIT_STATUS_CURRENT) {
- free(e);
+ git__free(e);
return GIT_SUCCESS;
}
@@ -446,7 +446,7 @@ int git_status_foreach(git_repository *repo, int (*callback)(const char *, unsig
error = git__rethrow(error, "Failed to determine statuses. User callback failed");
}
- free(e);
+ git__free(e);
}
exit:
@@ -550,7 +550,7 @@ int git_status_file(unsigned int *status_flags, git_repository *repo, const char
exit:
git_tree_close(tree);
- free(e);
+ git__free(e);
return error;
}
@@ -606,7 +606,7 @@ static int alphasorted_dirent_cb(void *state, char *full_path)
return GIT_ENOMEM;
if (git_vector_insert(entry_names, entry) < GIT_SUCCESS) {
- free(entry);
+ git__free(entry);
return GIT_ENOMEM;
}
@@ -639,7 +639,7 @@ static int alphasorted_futils_direach(
error = fn(arg, entry->path);
}
- free(entry);
+ git__free(entry);
}
git_vector_free(&entry_names);
diff --git a/src/tag.c b/src/tag.c
index ba75104ef..0bdca93bb 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -16,9 +16,9 @@
void git_tag__free(git_tag *tag)
{
git_signature_free(tag->tagger);
- free(tag->message);
- free(tag->tag_name);
- free(tag);
+ git__free(tag->message);
+ git__free(tag->tag_name);
+ git__free(tag);
}
const git_oid *git_tag_id(git_tag *c)
@@ -341,8 +341,8 @@ int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *bu
error = git_reference_set_oid(new_ref, oid);
git_signature_free(tag.tagger);
- free(tag.tag_name);
- free(tag.message);
+ git__free(tag.tag_name);
+ git__free(tag.message);
return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to create tag");
}
diff --git a/src/transports/git.c b/src/transports/git.c
index 489807851..c2014529b 100644
--- a/src/transports/git.c
+++ b/src/transports/git.c
@@ -109,8 +109,8 @@ static int do_connect(transport_git *t, const char *url)
error = send_request(s, NULL, url);
t->socket = s;
- free(host);
- free(port);
+ git__free(host);
+ git__free(port);
if (error < GIT_SUCCESS && s > 0)
close(s);
@@ -357,11 +357,11 @@ static int git_negotiate_fetch(git_transport *transport, git_repository *repo, g
gitno_consume(buf, line_end);
if (pkt->type == GIT_PKT_ACK) {
- free(pkt);
+ git__free(pkt);
error = GIT_SUCCESS;
goto done;
} else if (pkt->type == GIT_PKT_NAK) {
- free(pkt);
+ git__free(pkt);
break;
} else {
error = git__throw(GIT_ERROR, "Got unexpected pkt type");
@@ -424,12 +424,12 @@ static int git_download_pack(char **out, git_transport *transport, git_repositor
return error;
if (pkt->type == GIT_PKT_PACK) {
- free(pkt);
+ git__free(pkt);
return git_fetch__download_pack(out, buf->data, buf->offset, t->socket, repo);
}
/* For now we don't care about anything */
- free(pkt);
+ git__free(pkt);
gitno_consume(buf, line_end);
}
@@ -475,9 +475,9 @@ static void git_free(git_transport *transport)
}
git_vector_free(refs);
- free(t->heads);
- free(t->parent.url);
- free(t);
+ git__free(t->heads);
+ git__free(t->parent.url);
+ git__free(t);
}
int git_transport_git(git_transport **out)
diff --git a/src/transports/http.c b/src/transports/http.c
index 680354bae..a1a73cb00 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -389,18 +389,18 @@ static int on_body_parse_response(http_parser *parser, const char *str, size_t l
git_buf_consume(buf, line_end);
if (pkt->type == GIT_PKT_PACK) {
- free(pkt);
+ git__free(pkt);
t->pack_ready = 1;
return 0;
}
if (pkt->type == GIT_PKT_NAK) {
- free(pkt);
+ git__free(pkt);
return 0;
}
if (pkt->type != GIT_PKT_ACK) {
- free(pkt);
+ git__free(pkt);
continue;
}
@@ -749,13 +749,13 @@ static void http_free(git_transport *transport)
}
git_vector_free(common);
git_buf_free(&t->buf);
- free(t->heads);
- free(t->content_type);
- free(t->host);
- free(t->port);
- free(t->service);
- free(t->parent.url);
- free(t);
+ git__free(t->heads);
+ git__free(t->content_type);
+ git__free(t->host);
+ git__free(t->port);
+ git__free(t->service);
+ git__free(t->parent.url);
+ git__free(t);
}
int git_transport_http(git_transport **out)
diff --git a/src/transports/local.c b/src/transports/local.c
index 3f47e9b89..e09680478 100644
--- a/src/transports/local.c
+++ b/src/transports/local.c
@@ -113,8 +113,8 @@ static int add_ref(const char *name, git_repository *repo, git_vector *vec)
out:
git_object_close(obj);
if (error < GIT_SUCCESS) {
- free(head->name);
- free(head);
+ git__free(head->name);
+ git__free(head);
}
return error;
}
@@ -190,16 +190,16 @@ static void local_free(git_transport *transport)
if (t->refs != NULL) {
git_vector_foreach (vec, i, h) {
- free(h->name);
- free(h);
+ git__free(h->name);
+ git__free(h);
}
git_vector_free(vec);
- free(vec);
+ git__free(vec);
}
git_repository_free(t->repo);
- free(t->parent.url);
- free(t);
+ git__free(t->parent.url);
+ git__free(t);
}
/**************
diff --git a/src/tree-cache.c b/src/tree-cache.c
index 5a3257520..ea8b7bfb7 100644
--- a/src/tree-cache.c
+++ b/src/tree-cache.c
@@ -196,6 +196,6 @@ void git_tree_cache_free(git_tree_cache *tree)
for (i = 0; i < tree->children_count; ++i)
git_tree_cache_free(tree->children[i]);
- free(tree->children);
- free(tree);
+ git__free(tree->children);
+ git__free(tree);
}
diff --git a/src/tree.c b/src/tree.c
index 77034fa43..6efedcff5 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -130,12 +130,12 @@ void git_tree__free(git_tree *tree)
git_tree_entry *e;
e = git_vector_get(&tree->entries, i);
- free(e->filename);
- free(e);
+ git__free(e->filename);
+ git__free(e);
}
git_vector_free(&tree->entries);
- free(tree);
+ git__free(tree);
}
const git_oid *git_tree_id(git_tree *c)
@@ -378,7 +378,7 @@ static int write_tree(git_oid *oid, git_index *index, const char *dirname, unsig
last_comp = subdir;
}
error = append_entry(bld, last_comp, &sub_oid, S_IFDIR);
- free(subdir);
+ git__free(subdir);
if (error < GIT_SUCCESS) {
error = git__rethrow(error, "Failed to insert dir");
goto cleanup;
@@ -441,7 +441,7 @@ int git_treebuilder_create(git_treebuilder **builder_p, const git_tree *source)
source_entries = source->entries.length;
if (git_vector_init(&bld->entries, source_entries, entry_sort_cmp) < GIT_SUCCESS) {
- free(bld);
+ git__free(bld);
return GIT_ENOMEM;
}
@@ -596,8 +596,8 @@ void git_treebuilder_clear(git_treebuilder *bld)
for (i = 0; i < bld->entries.length; ++i) {
git_tree_entry *e = bld->entries.contents[i];
- free(e->filename);
- free(e);
+ git__free(e->filename);
+ git__free(e);
}
git_vector_clear(&bld->entries);
@@ -607,7 +607,7 @@ void git_treebuilder_free(git_treebuilder *bld)
{
git_treebuilder_clear(bld);
git_vector_free(&bld->entries);
- free(bld);
+ git__free(bld);
}
static int tree_frompath(git_tree **parent_out, git_tree *root, const char *treeentry_path, int offset)
diff --git a/src/tsort.c b/src/tsort.c
index 5dd99cc6e..df230b59d 100644
--- a/src/tsort.c
+++ b/src/tsort.c
@@ -178,7 +178,7 @@ static int check_invariant(struct tsort_run *stack, int stack_curr)
static int resize(struct tsort_store *store, size_t new_size)
{
if (store->alloc < new_size) {
- void **tempstore = realloc(store->storage, new_size * sizeof(void *));
+ void **tempstore = git__realloc(store->storage, new_size * sizeof(void *));
/**
* Do not propagate on OOM; this will abort the sort and
@@ -319,7 +319,7 @@ static ssize_t collapse(void **dst, struct tsort_run *stack, ssize_t stack_curr,
stack_curr--; \
} \
if (store->storage != NULL) {\
- free(store->storage);\
+ git__free(store->storage);\
store->storage = NULL;\
}\
return;\
diff --git a/src/util.c b/src/util.c
index c81ed2d3a..b3af7ffd8 100644
--- a/src/util.c
+++ b/src/util.c
@@ -26,9 +26,9 @@ void git_strarray_free(git_strarray *array)
{
size_t i;
for (i = 0; i < array->count; ++i)
- free(array->strings[i]);
+ git__free(array->strings[i]);
- free(array->strings);
+ git__free(array->strings);
}
int git__fnmatch(const char *pattern, const char *name, int flags)
diff --git a/src/util.h b/src/util.h
index 4de91b494..fbf9012a3 100644
--- a/src/util.h
+++ b/src/util.h
@@ -72,6 +72,8 @@ GIT_INLINE(void *) git__realloc(void *ptr, size_t size)
return new_ptr;
}
+#define git__free(ptr) free(ptr)
+
extern int git__prefixcmp(const char *str, const char *prefix);
extern int git__suffixcmp(const char *str, const char *suffix);
diff --git a/src/vector.c b/src/vector.c
index 8b20bb8ef..123aae8e6 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -18,7 +18,7 @@ static int resize_vector(git_vector *v)
if (v->_alloc_size < minimum_size)
v->_alloc_size = minimum_size;
- v->contents = realloc(v->contents, v->_alloc_size * sizeof(void *));
+ v->contents = git__realloc(v->contents, v->_alloc_size * sizeof(void *));
if (v->contents == NULL)
return GIT_ENOMEM;
@@ -29,7 +29,7 @@ static int resize_vector(git_vector *v)
void git_vector_free(git_vector *v)
{
assert(v);
- free(v->contents);
+ git__free(v->contents);
}
int git_vector_init(git_vector *v, unsigned int initial_size, git_vector_cmp cmp)
diff --git a/src/win32/dir.c b/src/win32/dir.c
index fea74b4eb..01aaaaad3 100644
--- a/src/win32/dir.c
+++ b/src/win32/dir.c
@@ -39,18 +39,18 @@ git__DIR *git__opendir(const char *dir)
new->dir = git__malloc(strlen(dir)+1);
if (!new->dir) {
- free(new);
+ git__free(new);
return NULL;
}
strcpy(new->dir, dir);
filter_w = gitwin_to_utf16(filter);
new->h = FindFirstFileW(filter_w, &new->f);
- free(filter_w);
+ git__free(filter_w);
if (new->h == INVALID_HANDLE_VALUE) {
- free(new->dir);
- free(new);
+ git__free(new->dir);
+ git__free(new);
return NULL;
}
new->first = 1;
@@ -93,7 +93,7 @@ void git__rewinddir(git__DIR *d)
if (init_filter(filter, sizeof(filter), d->dir)) {
filter_w = gitwin_to_utf16(filter);
d->h = FindFirstFileW(filter_w, &d->f);
- free(filter_w);
+ git__free(filter_w);
if (d->h != INVALID_HANDLE_VALUE)
d->first = 1;
@@ -107,8 +107,8 @@ int git__closedir(git__DIR *d)
if (d->h != INVALID_HANDLE_VALUE)
FindClose(d->h);
if (d->dir)
- free(d->dir);
- free(d);
+ git__free(d->dir);
+ git__free(d);
}
return 0;
}
diff --git a/src/win32/posix.h b/src/win32/posix.h
index 3774e7883..5dcdb5f85 100644
--- a/src/win32/posix.h
+++ b/src/win32/posix.h
@@ -26,7 +26,7 @@ GIT_INLINE(int) p_mkdir(const char *path, int GIT_UNUSED(mode))
GIT_UNUSED_ARG(mode)
- free(buf);
+ git__free(buf);
return ret;
}
diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c
index a05aafcca..ed7450a94 100644
--- a/src/win32/posix_w32.c
+++ b/src/win32/posix_w32.c
@@ -20,7 +20,7 @@ int p_unlink(const char *path)
buf = gitwin_to_utf16(path);
_wchmod(buf, 0666);
ret = _wunlink(buf);
- free(buf);
+ git__free(buf);
return ret;
}
@@ -86,11 +86,11 @@ static int do_lstat(const char *file_name, struct stat *buf)
buf->st_mtime = filetime_to_time_t(&(fdata.ftLastWriteTime));
buf->st_ctime = filetime_to_time_t(&(fdata.ftCreationTime));
- free(fbuf);
+ git__free(fbuf);
return GIT_SUCCESS;
}
- free(fbuf);
+ git__free(fbuf);
switch (GetLastError()) {
case ERROR_ACCESS_DENIED:
@@ -171,7 +171,7 @@ int p_readlink(const char *link, char *target, size_t target_len)
FILE_FLAG_BACKUP_SEMANTICS, // normal file
NULL); // no attr. template
- free(link_w);
+ git__free(link_w);
if (hFile == INVALID_HANDLE_VALUE)
return GIT_EOSERR;
@@ -184,17 +184,17 @@ int p_readlink(const char *link, char *target, size_t target_len)
dwRet = pGetFinalPath(hFile, target_w, target_len, 0x0);
if (dwRet >= target_len) {
- free(target_w);
+ git__free(target_w);
CloseHandle(hFile);
return GIT_ENOMEM;
}
if (!WideCharToMultiByte(CP_UTF8, 0, target_w, -1, target, target_len * sizeof(char), NULL, NULL)) {
- free(target_w);
+ git__free(target_w);
return GIT_EOSERR;
}
- free(target_w);
+ git__free(target_w);
CloseHandle(hFile);
if (dwRet > 4) {
@@ -226,7 +226,7 @@ int p_open(const char *path, int flags)
wchar_t* buf = gitwin_to_utf16(path);
fd = _wopen(buf, flags | _O_BINARY);
- free(buf);
+ git__free(buf);
return fd;
}
@@ -236,7 +236,7 @@ int p_creat(const char *path, int mode)
wchar_t* buf = gitwin_to_utf16(path);
fd = _wopen(buf, _O_WRONLY | _O_CREAT | _O_TRUNC | _O_BINARY, mode);
- free(buf);
+ git__free(buf);
return fd;
}
@@ -246,11 +246,11 @@ int p_getcwd(char *buffer_out, size_t size)
_wgetcwd(buf, (int)size);
if (!WideCharToMultiByte(CP_UTF8, 0, buf, -1, buffer_out, size, NULL, NULL)) {
- free(buf);
+ git__free(buf);
return GIT_EOSERR;
}
- free(buf);
+ git__free(buf);
return GIT_SUCCESS;
}
@@ -264,7 +264,7 @@ int p_chdir(const char* path)
wchar_t* buf = gitwin_to_utf16(path);
int ret = _wchdir(buf);
- free(buf);
+ git__free(buf);
return ret;
}
@@ -273,7 +273,7 @@ int p_chmod(const char* path, int mode)
wchar_t* buf = gitwin_to_utf16(path);
int ret = _wchmod(buf, mode);
- free(buf);
+ git__free(buf);
return ret;
}
@@ -282,7 +282,7 @@ int p_rmdir(const char* path)
wchar_t* buf = gitwin_to_utf16(path);
int ret = _wrmdir(buf);
- free(buf);
+ git__free(buf);
return ret;
}
@@ -294,7 +294,7 @@ int p_hide_directory__w32(const char *path)
error = SetFileAttributesW(buf, FILE_ATTRIBUTE_HIDDEN) != 0 ?
GIT_SUCCESS : GIT_ERROR; /* MSDN states a "non zero" value indicates a success */
- free(buf);
+ git__free(buf);
if (error < GIT_SUCCESS)
error = git__throw(GIT_EOSERR, "Failed to hide directory '%s'", path);
@@ -314,21 +314,21 @@ char *p_realpath(const char *orig_path, char *buffer)
}
ret = GetFullPathNameW(orig_path_w, GIT_PATH_MAX, buffer_w, NULL);
- free(orig_path_w);
+ git__free(orig_path_w);
if (!ret || ret > GIT_PATH_MAX) {
- free(buffer_w);
- if (alloc) free(buffer);
+ git__free(buffer_w);
+ if (alloc) git__free(buffer);
return NULL;
}
if (!WideCharToMultiByte(CP_UTF8, 0, buffer_w, -1, buffer, GIT_PATH_MAX, NULL, NULL)) {
- free(buffer_w);
- if (alloc) free(buffer);
+ git__free(buffer_w);
+ if (alloc) git__free(buffer);
}
- free(buffer_w);
+ git__free(buffer_w);
git_path_mkposix(buffer);
return buffer;
}
@@ -384,7 +384,7 @@ int p_access(const char* path, int mode)
int ret;
ret = _waccess(buf, mode);
- free(buf);
+ git__free(buf);
return ret;
}
diff --git a/src/win32/utf-conv.c b/src/win32/utf-conv.c
index cb607839e..b41c78f92 100644
--- a/src/win32/utf-conv.c
+++ b/src/win32/utf-conv.c
@@ -50,7 +50,7 @@ wchar_t* gitwin_to_utf16(const char* str)
ret = (wchar_t*)git__malloc(cb);
if (MultiByteToWideChar(_active_codepage, 0, str, -1, ret, cb) == 0) {
- free(ret);
+ git__free(ret);
ret = NULL;
}
@@ -79,7 +79,7 @@ char* gitwin_from_utf16(const wchar_t* str)
ret = (char*)git__malloc(cb);
if (WideCharToMultiByte(_active_codepage, 0, str, -1, ret, cb, NULL, NULL) == 0) {
- free(ret);
+ git__free(ret);
ret = NULL;
}
diff --git a/tests-clay/core/path.c b/tests-clay/core/path.c
index db8f33d21..c394c7285 100644
--- a/tests-clay/core/path.c
+++ b/tests-clay/core/path.c
@@ -11,7 +11,7 @@ check_dirname(const char *A, const char *B)
cl_assert((dir2 = git_path_dirname(A)) != NULL);
cl_assert(strcmp(dir2, B) == 0);
- free(dir2);
+ git__free(dir2);
}
static void
@@ -24,7 +24,7 @@ check_basename(const char *A, const char *B)
cl_assert((base2 = git_path_basename(A)) != NULL);
cl_assert(strcmp(base2, B) == 0);
- free(base2);
+ git__free(base2);
}
static void
diff --git a/tests-clay/core/vector.c b/tests-clay/core/vector.c
index 44e6d873d..b8a853c60 100644
--- a/tests-clay/core/vector.c
+++ b/tests-clay/core/vector.c
@@ -59,8 +59,8 @@ void test_core_vector__2(void)
git_vector_free(&x);
- free(ptrs[0]);
- free(ptrs[1]);
+ git__free(ptrs[0]);
+ git__free(ptrs[1]);
}
diff --git a/tests-clay/object/raw/compare.c b/tests-clay/object/raw/compare.c
index 45e5331be..94b196945 100644
--- a/tests-clay/object/raw/compare.c
+++ b/tests-clay/object/raw/compare.c
@@ -101,7 +101,7 @@ void test_object_raw_compare__compare_allocfmt_oids(void)
out = git_oid_allocfmt(&in);
cl_assert(out);
cl_assert(strcmp(exp, out) == 0);
- free(out);
+ git__free(out);
}
void test_object_raw_compare__compare_pathfmt_oids(void)
diff --git a/tests-clay/object/raw/short.c b/tests-clay/object/raw/short.c
index 46e4fba2c..996f3f7b4 100644
--- a/tests-clay/object/raw/short.c
+++ b/tests-clay/object/raw/short.c
@@ -86,7 +86,7 @@ void test_object_raw_short__oid_shortener_stresstest_git_oid_shorten(void)
/* cleanup */
for (i = 0; i < MAX_OIDS; ++i)
- free(oids[i]);
+ git__free(oids[i]);
git_oid_shorten_free(os);
diff --git a/tests/t00-core.c b/tests/t00-core.c
index 703504bf8..f93444d57 100644
--- a/tests/t00-core.c
+++ b/tests/t00-core.c
@@ -99,8 +99,8 @@ BEGIN_TEST(vector2, "remove duplicates")
must_be_true(x.length == 2);
git_vector_free(&x);
- free(ptrs[0]);
- free(ptrs[1]);
+ git__free(ptrs[0]);
+ git__free(ptrs[1]);
END_TEST
@@ -112,7 +112,7 @@ BEGIN_TEST(path0, "get the dirname of a path")
must_be_true(strcmp(dir, B) == 0); \
must_be_true((dir2 = git_path_dirname(A)) != NULL); \
must_be_true(strcmp(dir2, B) == 0); \
- free(dir2); \
+ git__free(dir2); \
}
DIRNAME_TEST(NULL, ".");
@@ -141,7 +141,7 @@ BEGIN_TEST(path1, "get the base name of a path")
must_be_true(strcmp(base, B) == 0); \
must_be_true((base2 = git_path_basename(A)) != NULL); \
must_be_true(strcmp(base2, B) == 0); \
- free(base2); \
+ git__free(base2); \
}
BASENAME_TEST(NULL, ".");
diff --git a/tests/t01-rawobj.c b/tests/t01-rawobj.c
index 255208532..8b05f3394 100644
--- a/tests/t01-rawobj.c
+++ b/tests/t01-rawobj.c
@@ -217,7 +217,7 @@ BEGIN_TEST(oid12, "compare oids (allocate + format)")
out = git_oid_allocfmt(&in);
must_be_true(out);
must_be_true(strcmp(exp, out) == 0);
- free(out);
+ git__free(out);
END_TEST
BEGIN_TEST(oid13, "compare oids (path format)")
@@ -390,7 +390,7 @@ BEGIN_TEST(oid17, "stress test for the git_oid_shorten object")
/* cleanup */
for (i = 0; i < MAX_OIDS; ++i)
- free(oids[i]);
+ git__free(oids[i]);
git_oid_shorten_free(os);
diff --git a/tests/t04-commit.c b/tests/t04-commit.c
index 3fb4d370c..303b8f7cb 100644
--- a/tests/t04-commit.c
+++ b/tests/t04-commit.c
@@ -162,7 +162,7 @@ BEGIN_TEST(parse1, "parse the signature line in a commit")
must_be_true(strcmp(_email, person.email) == 0);\
must_be_true(_time == person.when.time);\
must_be_true(_offset == person.when.offset);\
- free(person.name); free(person.email);\
+ git__free(person.name); git__free(person.email);\
}
#define TEST_SIGNATURE_FAIL(_string, _header) { \
@@ -170,7 +170,7 @@ BEGIN_TEST(parse1, "parse the signature line in a commit")
size_t len = strlen(_string);\
git_signature person = {NULL, NULL, {0, 0}}; \
must_fail(git_signature__parse(&person, &ptr, ptr + len, _header, '\n'));\
- free(person.name); free(person.email);\
+ git__free(person.name); git__free(person.email);\
}
TEST_SIGNATURE_PASS(
@@ -759,7 +759,7 @@ BEGIN_TEST(root0, "create a root commit")
must_pass(git_reference_set_target(head, head_old));
must_pass(git_reference_delete(branch));
must_pass(remove_loose_object(REPOSITORY_FOLDER, (git_object *)commit));
- free(head_old);
+ git__free(head_old);
git_commit_close(commit);
git_repository_free(repo);
END_TEST
diff --git a/tests/t07-hashtable.c b/tests/t07-hashtable.c
index c0e852259..41d52af19 100644
--- a/tests/t07-hashtable.c
+++ b/tests/t07-hashtable.c
@@ -103,7 +103,7 @@ BEGIN_TEST(table1, "fill the hashtable with random entries")
}
git_hashtable_free(table);
- free(objects);
+ git__free(objects);
END_TEST
@@ -145,7 +145,7 @@ BEGIN_TEST(table2, "make sure the table resizes automatically")
}
git_hashtable_free(table);
- free(objects);
+ git__free(objects);
END_TEST
@@ -179,7 +179,7 @@ BEGIN_TEST(tableit0, "iterate through all the contents of the table")
must_be_true(objects[i].visited);
git_hashtable_free(table);
- free(objects);
+ git__free(objects);
END_TEST
diff --git a/tests/test_helpers.c b/tests/test_helpers.c
index cb95607e1..d1d7c9ebd 100644
--- a/tests/test_helpers.c
+++ b/tests/test_helpers.c
@@ -116,7 +116,7 @@ int remove_loose_object(const char *repository_folder, git_object *object)
return -1;
}
- free(full_path);
+ git__free(full_path);
return GIT_SUCCESS;
}