Commit 3286c408 by Vicent Marti

global: Properly use `git__` memory wrappers

Ensure that all memory related functions (malloc, calloc, strdup, free,
etc) are using their respective `git__` wrappers.
parent da37654d
...@@ -119,7 +119,7 @@ int fetch(git_repository *repo, int argc, char **argv) ...@@ -119,7 +119,7 @@ int fetch(git_repository *repo, int argc, char **argv)
if (error < GIT_SUCCESS) if (error < GIT_SUCCESS)
return error; return error;
free(packname); git__free(packname);
git_indexer_free(idx); git_indexer_free(idx);
git_remote_free(remote); git_remote_free(remote);
......
...@@ -100,7 +100,7 @@ GIT_EXTERN(void) git_oid_pathfmt(char *str, const git_oid *oid); ...@@ -100,7 +100,7 @@ GIT_EXTERN(void) git_oid_pathfmt(char *str, const git_oid *oid);
* *
* @param oid the oid structure to format * @param oid the oid structure to format
* @return the c-string; NULL if memory is exhausted. Caller must * @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); GIT_EXTERN(char *) git_oid_allocfmt(const git_oid *oid);
......
...@@ -27,7 +27,7 @@ size_t git_blob_rawsize(git_blob *blob) ...@@ -27,7 +27,7 @@ size_t git_blob_rawsize(git_blob *blob)
void git_blob__free(git_blob *blob) void git_blob__free(git_blob *blob)
{ {
git_odb_object_close(blob->odb_object); git_odb_object_close(blob->odb_object);
free(blob); git__free(blob);
} }
int git_blob__parse(git_blob *blob, git_odb_object *odb_obj) int git_blob__parse(git_blob *blob, git_odb_object *odb_obj)
......
...@@ -97,7 +97,7 @@ const char *git_buf_cstr(git_buf *buf) ...@@ -97,7 +97,7 @@ const char *git_buf_cstr(git_buf *buf)
void git_buf_free(git_buf *buf) void git_buf_free(git_buf *buf)
{ {
free(buf->ptr); git__free(buf->ptr);
} }
void git_buf_clear(git_buf *buf) void git_buf_clear(git_buf *buf)
......
...@@ -53,7 +53,7 @@ void git_cache_free(git_cache *cache) ...@@ -53,7 +53,7 @@ void git_cache_free(git_cache *cache)
git_mutex_free(&cache->nodes[i].lock); 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) void *git_cache_get(git_cache *cache, const git_oid *oid)
......
...@@ -32,7 +32,7 @@ static void clear_parents(git_commit *commit) ...@@ -32,7 +32,7 @@ static void clear_parents(git_commit *commit)
for (i = 0; i < commit->parent_oids.length; ++i) { for (i = 0; i < commit->parent_oids.length; ++i) {
git_oid *parent = git_vector_get(&commit->parent_oids, i); git_oid *parent = git_vector_get(&commit->parent_oids, i);
free(parent); git__free(parent);
} }
git_vector_clear(&commit->parent_oids); git_vector_clear(&commit->parent_oids);
...@@ -46,9 +46,9 @@ void git_commit__free(git_commit *commit) ...@@ -46,9 +46,9 @@ void git_commit__free(git_commit *commit)
git_signature_free(commit->author); git_signature_free(commit->author);
git_signature_free(commit->committer); git_signature_free(commit->committer);
free(commit->message); git__free(commit->message);
free(commit->message_encoding); git__free(commit->message_encoding);
free(commit); git__free(commit);
} }
const git_oid *git_commit_id(git_commit *c) const git_oid *git_commit_id(git_commit *c)
...@@ -84,7 +84,7 @@ int git_commit_create_v( ...@@ -84,7 +84,7 @@ int git_commit_create_v(
message_encoding, message, message_encoding, message,
tree, parent_count, parents); tree, parent_count, parents);
free((void *)parents); git__free((void *)parents);
return error; return error;
} }
......
...@@ -35,11 +35,11 @@ void git_config_free(git_config *cfg) ...@@ -35,11 +35,11 @@ void git_config_free(git_config *cfg)
internal = git_vector_get(&cfg->files, i); internal = git_vector_get(&cfg->files, i);
file = internal->file; file = internal->file;
file->free(file); file->free(file);
free(internal); git__free(internal);
} }
git_vector_free(&cfg->files); git_vector_free(&cfg->files);
free(cfg); git__free(cfg);
} }
static int config_backend_cmp(const void *a, const void *b) static int config_backend_cmp(const void *a, const void *b)
...@@ -61,7 +61,7 @@ int git_config_new(git_config **out) ...@@ -61,7 +61,7 @@ int git_config_new(git_config **out)
memset(cfg, 0x0, sizeof(git_config)); memset(cfg, 0x0, sizeof(git_config));
if (git_vector_init(&cfg->files, 3, config_backend_cmp) < 0) { if (git_vector_init(&cfg->files, 3, config_backend_cmp) < 0) {
free(cfg); git__free(cfg);
return GIT_ENOMEM; return GIT_ENOMEM;
} }
...@@ -125,7 +125,7 @@ int git_config_add_file(git_config *cfg, git_config_file *file, int priority) ...@@ -125,7 +125,7 @@ int git_config_add_file(git_config *cfg, git_config_file *file, int priority)
internal->priority = priority; internal->priority = priority;
if (git_vector_insert(&cfg->files, internal) < 0) { if (git_vector_insert(&cfg->files, internal) < 0) {
free(internal); git__free(internal);
return GIT_ENOMEM; return GIT_ENOMEM;
} }
...@@ -366,20 +366,20 @@ static int win32_find_system(char *system_config_path) ...@@ -366,20 +366,20 @@ static int win32_find_system(char *system_config_path)
return git__throw(GIT_ERROR, "Failed to expand environment strings"); return git__throw(GIT_ERROR, "Failed to expand environment strings");
if (_waccess(apphome_utf16, F_OK) < 0) { if (_waccess(apphome_utf16, F_OK) < 0) {
free(apphome_utf16); git__free(apphome_utf16);
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
} }
apphome_utf8 = gitwin_from_utf16(apphome_utf16); apphome_utf8 = gitwin_from_utf16(apphome_utf16);
free(apphome_utf16); git__free(apphome_utf16);
if (strlen(apphome_utf8) >= GIT_PATH_MAX) { if (strlen(apphome_utf8) >= GIT_PATH_MAX) {
free(apphome_utf8); git__free(apphome_utf8);
return git__throw(GIT_ESHORTBUFFER, "Path is too long"); return git__throw(GIT_ESHORTBUFFER, "Path is too long");
} }
strcpy(system_config_path, apphome_utf8); strcpy(system_config_path, apphome_utf8);
free(apphome_utf8); git__free(apphome_utf8);
return GIT_SUCCESS; return GIT_SUCCESS;
} }
#endif #endif
......
...@@ -90,10 +90,10 @@ static void cvar_free(cvar_t *var) ...@@ -90,10 +90,10 @@ static void cvar_free(cvar_t *var)
if (var == NULL) if (var == NULL)
return; return;
free(var->section); git__free(var->section);
free(var->name); git__free(var->name);
free(var->value); git__free(var->value);
free(var); git__free(var);
} }
static void cvar_list_free(cvar_t_list *list) static void cvar_list_free(cvar_t_list *list)
...@@ -188,7 +188,7 @@ static int cvar_normalize_name(cvar_t *var, char **output) ...@@ -188,7 +188,7 @@ static int cvar_normalize_name(cvar_t *var, char **output)
if (section_sp == NULL) { if (section_sp == NULL) {
ret = p_snprintf(name, len + 1, "%s.%s", var->section, var->name); ret = p_snprintf(name, len + 1, "%s.%s", var->section, var->name);
if (ret < 0) { if (ret < 0) {
free(name); git__free(name);
return git__throw(GIT_EOSERR, "Failed to normalize name. OS err: %s", strerror(errno)); 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) ...@@ -281,10 +281,10 @@ static void backend_free(git_config_file *_backend)
if (backend == NULL) if (backend == NULL)
return; return;
free(backend->file_path); git__free(backend->file_path);
cvar_list_free(&backend->var_list); 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) 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 ...@@ -301,7 +301,7 @@ static int file_foreach(git_config_file *backend, int (*fn)(const char *, const
return ret; return ret;
ret = fn(normalized, var->value, data); ret = fn(normalized, var->value, data);
free(normalized); git__free(normalized);
if (ret) if (ret)
break; break;
} }
...@@ -326,7 +326,7 @@ static int config_set(git_config_file *cfg, const char *name, const char *value) ...@@ -326,7 +326,7 @@ static int config_set(git_config_file *cfg, const char *name, const char *value)
if (tmp == NULL && value != NULL) if (tmp == NULL && value != NULL)
return GIT_ENOMEM; return GIT_ENOMEM;
free(existing->value); git__free(existing->value);
existing->value = tmp; existing->value = tmp;
return config_write(b, existing); return config_write(b, existing);
...@@ -411,7 +411,7 @@ int git_config_file__ondisk(git_config_file **out, const char *path) ...@@ -411,7 +411,7 @@ int git_config_file__ondisk(git_config_file **out, const char *path)
backend->file_path = git__strdup(path); backend->file_path = git__strdup(path);
if (backend->file_path == NULL) { if (backend->file_path == NULL) {
free(backend); git__free(backend);
return GIT_ENOMEM; return GIT_ENOMEM;
} }
...@@ -653,13 +653,13 @@ static int parse_section_header(diskfile_backend *cfg, char **section_out) ...@@ -653,13 +653,13 @@ static int parse_section_header(diskfile_backend *cfg, char **section_out)
/* find the end of the variable's name */ /* find the end of the variable's name */
name_end = strchr(line, ']'); name_end = strchr(line, ']');
if (name_end == NULL) { if (name_end == NULL) {
free(line); git__free(line);
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse header. Can't find header name end"); 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); name = (char *)git__malloc((size_t)(name_end - line) + 1);
if (name == NULL) { if (name == NULL) {
free(line); git__free(line);
return GIT_ENOMEM; return GIT_ENOMEM;
} }
...@@ -679,8 +679,8 @@ static int parse_section_header(diskfile_backend *cfg, char **section_out) ...@@ -679,8 +679,8 @@ static int parse_section_header(diskfile_backend *cfg, char **section_out)
if (isspace(c)){ if (isspace(c)){
name[name_length] = '\0'; name[name_length] = '\0';
error = parse_section_header_ext(line, name, section_out); error = parse_section_header_ext(line, name, section_out);
free(line); git__free(line);
free(name); git__free(name);
return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to parse header"); 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) ...@@ -699,14 +699,14 @@ static int parse_section_header(diskfile_backend *cfg, char **section_out)
} }
name[name_length] = 0; name[name_length] = 0;
free(line); git__free(line);
git__strtolower(name); git__strtolower(name);
*section_out = name; *section_out = name;
return GIT_SUCCESS; return GIT_SUCCESS;
error: error:
free(line); git__free(line);
free(name); git__free(name);
return error; return error;
} }
...@@ -810,7 +810,7 @@ static int config_parse(diskfile_backend *cfg_file) ...@@ -810,7 +810,7 @@ static int config_parse(diskfile_backend *cfg_file)
break; break;
case '[': /* section header, new section begins */ case '[': /* section header, new section begins */
free(current_section); git__free(current_section);
current_section = NULL; current_section = NULL;
error = parse_section_header(cfg_file, &current_section); error = parse_section_header(cfg_file, &current_section);
break; break;
...@@ -826,7 +826,7 @@ static int config_parse(diskfile_backend *cfg_file) ...@@ -826,7 +826,7 @@ static int config_parse(diskfile_backend *cfg_file)
if (error < GIT_SUCCESS) if (error < GIT_SUCCESS)
break; break;
var = malloc(sizeof(cvar_t)); var = git__malloc(sizeof(cvar_t));
if (var == NULL) { if (var == NULL) {
error = GIT_ENOMEM; error = GIT_ENOMEM;
break; break;
...@@ -837,7 +837,7 @@ static int config_parse(diskfile_backend *cfg_file) ...@@ -837,7 +837,7 @@ static int config_parse(diskfile_backend *cfg_file)
var->section = git__strdup(current_section); var->section = git__strdup(current_section);
if (var->section == NULL) { if (var->section == NULL) {
error = GIT_ENOMEM; error = GIT_ENOMEM;
free(var); git__free(var);
break; break;
} }
...@@ -851,7 +851,7 @@ static int config_parse(diskfile_backend *cfg_file) ...@@ -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"); 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) ...@@ -915,7 +915,7 @@ static int config_write(diskfile_backend *cfg, cvar_t *var)
*/ */
pre_end = post_start = cfg->reader.read_ptr; pre_end = post_start = cfg->reader.read_ptr;
if (current_section) if (current_section)
free(current_section); git__free(current_section);
error = parse_section_header(cfg, &current_section); error = parse_section_header(cfg, &current_section);
if (error < GIT_SUCCESS) if (error < GIT_SUCCESS)
break; break;
...@@ -953,8 +953,8 @@ static int config_write(diskfile_backend *cfg, cvar_t *var) ...@@ -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) if ((error = parse_variable(cfg, &var_name, &var_value)) == GIT_SUCCESS)
cmp = strcasecmp(var->name, var_name); cmp = strcasecmp(var->name, var_name);
free(var_name); git__free(var_name);
free(var_value); git__free(var_value);
if (cmp != 0) if (cmp != 0)
break; break;
...@@ -1029,7 +1029,7 @@ static int config_write(diskfile_backend *cfg, cvar_t *var) ...@@ -1029,7 +1029,7 @@ static int config_write(diskfile_backend *cfg, cvar_t *var)
git__rethrow(error, "Failed to write new section"); git__rethrow(error, "Failed to write new section");
cleanup: cleanup:
free(current_section); git__free(current_section);
if (error < GIT_SUCCESS) if (error < GIT_SUCCESS)
git_filebuf_cleanup(&file); git_filebuf_cleanup(&file);
...@@ -1093,7 +1093,7 @@ static int parse_multiline_variable(diskfile_backend *cfg, const char *first, ch ...@@ -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); ret = p_snprintf(buf, len, "%s %s", first, line);
if (ret < 0) { if (ret < 0) {
error = git__throw(GIT_EOSERR, "Failed to parse multiline var. Failed to put together two lines. OS err: %s", strerror(errno)); 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; goto out;
} }
...@@ -1105,14 +1105,14 @@ static int parse_multiline_variable(diskfile_backend *cfg, const char *first, ch ...@@ -1105,14 +1105,14 @@ static int parse_multiline_variable(diskfile_backend *cfg, const char *first, ch
if (is_multiline_var(buf)) { if (is_multiline_var(buf)) {
char *final_val; char *final_val;
error = parse_multiline_variable(cfg, buf, &final_val); error = parse_multiline_variable(cfg, buf, &final_val);
free(buf); git__free(buf);
buf = final_val; buf = final_val;
} }
*out = buf; *out = buf;
out: out:
free(line); git__free(line);
return error; return error;
} }
...@@ -1168,14 +1168,14 @@ static int parse_variable(diskfile_backend *cfg, char **var_name, char **var_val ...@@ -1168,14 +1168,14 @@ static int parse_variable(diskfile_backend *cfg, char **var_name, char **var_val
if (error != GIT_SUCCESS) if (error != GIT_SUCCESS)
{ {
*var_value = NULL; *var_value = NULL;
free(*var_name); git__free(*var_name);
} }
goto out; goto out;
} }
tmp = strdup(value_start); tmp = git__strdup(value_start);
if (tmp == NULL) { if (tmp == NULL) {
free(*var_name); git__free(*var_name);
*var_value = NULL; *var_value = NULL;
error = GIT_ENOMEM; error = GIT_ENOMEM;
goto out; goto out;
...@@ -1188,6 +1188,6 @@ static int parse_variable(diskfile_backend *cfg, char **var_name, char **var_val ...@@ -1188,6 +1188,6 @@ static int parse_variable(diskfile_backend *cfg, char **var_name, char **var_val
} }
out: out:
free(line); git__free(line);
return error; return error;
} }
...@@ -109,7 +109,7 @@ int git__delta_apply( ...@@ -109,7 +109,7 @@ int git__delta_apply(
return GIT_SUCCESS; return GIT_SUCCESS;
fail: fail:
free(out->data); git__free(out->data);
out->data = NULL; out->data = NULL;
return git__throw(GIT_ERROR, "Failed to apply delta"); return git__throw(GIT_ERROR, "Failed to apply delta");
} }
...@@ -70,9 +70,9 @@ void git___rethrow(const char *msg, ...) ...@@ -70,9 +70,9 @@ void git___rethrow(const char *msg, ...)
vsnprintf(new_error, sizeof(new_error), msg, va); vsnprintf(new_error, sizeof(new_error), msg, va);
va_end(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); 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, ...) void git___throw(const char *msg, ...)
......
...@@ -63,13 +63,13 @@ void git_filebuf_cleanup(git_filebuf *file) ...@@ -63,13 +63,13 @@ void git_filebuf_cleanup(git_filebuf *file)
if (file->digest) if (file->digest)
git_hash_free_ctx(file->digest); git_hash_free_ctx(file->digest);
free(file->buffer); git__free(file->buffer);
free(file->z_buf); git__free(file->z_buf);
deflateEnd(&file->zs); deflateEnd(&file->zs);
free(file->path_original); git__free(file->path_original);
free(file->path_lock); git__free(file->path_lock);
} }
GIT_INLINE(int) flush_buffer(git_filebuf *file) GIT_INLINE(int) flush_buffer(git_filebuf *file)
...@@ -248,7 +248,7 @@ int git_filebuf_hash(git_oid *oid, 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) 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); file->path_original = git__strdup(path);
if (file->path_original == NULL) if (file->path_original == NULL)
return GIT_ENOMEM; return GIT_ENOMEM;
...@@ -368,12 +368,12 @@ int git_filebuf_printf(git_filebuf *file, const char *format, ...) ...@@ -368,12 +368,12 @@ int git_filebuf_printf(git_filebuf *file, const char *format, ...)
va_end(arglist); va_end(arglist);
if (len < 0) { if (len < 0) {
free(tmp_buffer); git__free(tmp_buffer);
return git__throw(GIT_EOSERR, "Failed to format string"); return git__throw(GIT_EOSERR, "Failed to format string");
} }
error = git_filebuf_write(file, tmp_buffer, len); error = git_filebuf_write(file, tmp_buffer, len);
free(tmp_buffer); git__free(tmp_buffer);
return error; return error;
} }
......
...@@ -181,7 +181,7 @@ int git_futils_readbuffer_updated(git_fbuffer *obj, const char *path, time_t *mt ...@@ -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) { if (p_read(fd, buff, len) < 0) {
p_close(fd); p_close(fd);
free(buff); git__free(buff);
return git__throw(GIT_ERROR, "Failed to read file `%s`", path); return git__throw(GIT_ERROR, "Failed to read file `%s`", path);
} }
buff[len] = '\0'; buff[len] = '\0';
...@@ -207,7 +207,7 @@ int git_futils_readbuffer(git_fbuffer *obj, const char *path) ...@@ -207,7 +207,7 @@ int git_futils_readbuffer(git_fbuffer *obj, const char *path)
void git_futils_freebuffer(git_fbuffer *obj) void git_futils_freebuffer(git_fbuffer *obj)
{ {
assert(obj); assert(obj);
free(obj->data); git__free(obj->data);
obj->data = NULL; obj->data = NULL;
} }
...@@ -326,7 +326,7 @@ int git_futils_mkdir_r(const char *path, int mode) ...@@ -326,7 +326,7 @@ int git_futils_mkdir_r(const char *path, int mode)
error = GIT_SUCCESS; error = GIT_SUCCESS;
} }
free(path_copy); git__free(path_copy);
if (error < GIT_SUCCESS) if (error < GIT_SUCCESS)
return git__throw(error, "Failed to recursively create `%s` tree structure", path); return git__throw(error, "Failed to recursively create `%s` tree structure", path);
......
...@@ -32,7 +32,7 @@ git_hash_ctx *git_hash_new_ctx(void) ...@@ -32,7 +32,7 @@ git_hash_ctx *git_hash_new_ctx(void)
void git_hash_free_ctx(git_hash_ctx *ctx) void git_hash_free_ctx(git_hash_ctx *ctx)
{ {
free(ctx); git__free(ctx);
} }
void git_hash_init(git_hash_ctx *ctx) void git_hash_init(git_hash_ctx *ctx)
......
...@@ -39,17 +39,17 @@ static int resize_to(git_hashtable *self, size_t new_size) ...@@ -39,17 +39,17 @@ static int resize_to(git_hashtable *self, size_t new_size)
self->is_resizing = 0; self->is_resizing = 0;
else { else {
new_size *= 2; new_size *= 2;
free(self->nodes); git__free(self->nodes);
} }
} while(self->is_resizing); } while(self->is_resizing);
free(old_nodes); git__free(old_nodes);
return GIT_SUCCESS; return GIT_SUCCESS;
} }
static int set_size(git_hashtable *self, size_t new_size) 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) if (self->nodes == NULL)
return GIT_ENOMEM; return GIT_ENOMEM;
...@@ -156,8 +156,8 @@ void git_hashtable_free(git_hashtable *self) ...@@ -156,8 +156,8 @@ void git_hashtable_free(git_hashtable *self)
{ {
assert(self); assert(self);
free(self->nodes); git__free(self->nodes);
free(self); git__free(self);
} }
......
...@@ -138,7 +138,7 @@ static int index_initialize(git_index **index_out, git_repository *owner, const ...@@ -138,7 +138,7 @@ static int index_initialize(git_index **index_out, git_repository *owner, const
index->index_file_path = git__strdup(index_path); index->index_file_path = git__strdup(index_path);
if (index->index_file_path == NULL) { if (index->index_file_path == NULL) {
free(index); git__free(index);
return GIT_ENOMEM; return GIT_ENOMEM;
} }
...@@ -179,8 +179,8 @@ void git_index_free(git_index *index) ...@@ -179,8 +179,8 @@ void git_index_free(git_index *index)
git_vector_free(&index->entries); git_vector_free(&index->entries);
git_vector_free(&index->unmerged); git_vector_free(&index->unmerged);
free(index->index_file_path); git__free(index->index_file_path);
free(index); git__free(index);
} }
void git_index_clear(git_index *index) void git_index_clear(git_index *index)
...@@ -192,15 +192,15 @@ 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) { for (i = 0; i < index->entries.length; ++i) {
git_index_entry *e; git_index_entry *e;
e = git_vector_get(&index->entries, i); e = git_vector_get(&index->entries, i);
free(e->path); git__free(e->path);
free(e); git__free(e);
} }
for (i = 0; i < index->unmerged.length; ++i) { for (i = 0; i < index->unmerged.length; ++i) {
git_index_entry_unmerged *e; git_index_entry_unmerged *e;
e = git_vector_get(&index->unmerged, i); e = git_vector_get(&index->unmerged, i);
free(e->path); git__free(e->path);
free(e); git__free(e);
} }
git_vector_clear(&index->entries); git_vector_clear(&index->entries);
...@@ -334,7 +334,7 @@ static int index_entry_init(git_index_entry **entry_out, git_index *index, const ...@@ -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->flags |= (stage << GIT_IDXENTRY_STAGESHIFT);
entry->path = git__strdup(rel_path); entry->path = git__strdup(rel_path);
if (entry->path == NULL) { if (entry->path == NULL) {
free(entry); git__free(entry);
return GIT_ENOMEM; return GIT_ENOMEM;
} }
...@@ -364,8 +364,8 @@ static void index_entry_free(git_index_entry *entry) ...@@ -364,8 +364,8 @@ static void index_entry_free(git_index_entry *entry)
{ {
if (!entry) if (!entry)
return; return;
free(entry->path); git__free(entry->path);
free(entry); git__free(entry);
} }
static int index_insert(git_index *index, git_index_entry *entry, int replace) 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) ...@@ -416,8 +416,8 @@ static int index_insert(git_index *index, git_index_entry *entry, int replace)
/* exists, replace it */ /* exists, replace it */
entry_array = (git_index_entry **) index->entries.contents; entry_array = (git_index_entry **) index->entries.contents;
free(entry_array[position]->path); git__free(entry_array[position]->path);
free(entry_array[position]); git__free(entry_array[position]);
entry_array[position] = entry; entry_array[position] = entry;
return GIT_SUCCESS; return GIT_SUCCESS;
......
...@@ -367,7 +367,7 @@ int git_indexer_run(git_indexer *idx, git_indexer_stats *stats) ...@@ -367,7 +367,7 @@ int git_indexer_run(git_indexer *idx, git_indexer_stats *stats)
idx->fanout[i]++; idx->fanout[i]++;
} }
free(obj.data); git__free(obj.data);
stats->processed = ++processed; stats->processed = ++processed;
} }
...@@ -390,12 +390,12 @@ void git_indexer_free(git_indexer *idx) ...@@ -390,12 +390,12 @@ void git_indexer_free(git_indexer *idx)
p_close(idx->pack->mwf.fd); p_close(idx->pack->mwf.fd);
git_vector_foreach(&idx->objects, i, e) git_vector_foreach(&idx->objects, i, e)
free(e); git__free(e);
git_vector_free(&idx->objects); git_vector_free(&idx->objects);
git_vector_foreach(&idx->pack->cache, i, pe) git_vector_foreach(&idx->pack->cache, i, pe)
free(pe); git__free(pe);
git_vector_free(&idx->pack->cache); git_vector_free(&idx->pack->cache);
free(idx->pack); git__free(idx->pack);
free(idx); git__free(idx);
} }
...@@ -69,7 +69,7 @@ void git_mwindow_free_all(git_mwindow_file *mwf) ...@@ -69,7 +69,7 @@ void git_mwindow_free_all(git_mwindow_file *mwf)
git_futils_mmap_free(&w->window_map); git_futils_mmap_free(&w->window_map);
mwf->windows = w->next; mwf->windows = w->next;
free(w); git__free(w);
} }
} }
...@@ -139,7 +139,7 @@ static int git_mwindow_close_lru(git_mwindow_file *mwf) ...@@ -139,7 +139,7 @@ static int git_mwindow_close_lru(git_mwindow_file *mwf)
else else
*list = lru_w->next; *list = lru_w->next;
free(lru_w); git__free(lru_w);
ctl.open_windows--; ctl.open_windows--;
return GIT_SUCCESS; return GIT_SUCCESS;
...@@ -191,7 +191,7 @@ static git_mwindow *new_window(git_mwindow_file *mwf, git_file fd, git_off_t siz ...@@ -191,7 +191,7 @@ static git_mwindow *new_window(git_mwindow_file *mwf, git_file fd, git_off_t siz
return w; return w;
cleanup: cleanup:
free(w); git__free(w);
return NULL; return NULL;
} }
......
...@@ -190,7 +190,7 @@ int gitno_extract_host_and_port(char **host, char **port, const char *url, const ...@@ -190,7 +190,7 @@ int gitno_extract_host_and_port(char **host, char **port, const char *url, const
delim = colon == NULL ? slash : colon; delim = colon == NULL ? slash : colon;
*host = git__strndup(url, delim - url); *host = git__strndup(url, delim - url);
if (*host == NULL) { if (*host == NULL) {
free(*port); git__free(*port);
error = GIT_ENOMEM; error = GIT_ENOMEM;
} }
......
...@@ -213,7 +213,7 @@ void git_object__free(void *_obj) ...@@ -213,7 +213,7 @@ void git_object__free(void *_obj)
break; break;
default: default:
free(object); git__free(object);
break; break;
} }
} }
......
...@@ -83,8 +83,8 @@ static void free_odb_object(void *o) ...@@ -83,8 +83,8 @@ static void free_odb_object(void *o)
git_odb_object *object = (git_odb_object *)o; git_odb_object *object = (git_odb_object *)o;
if (object != NULL) { if (object != NULL) {
free(object->raw.data); git__free(object->raw.data);
free(object); git__free(object);
} }
} }
...@@ -205,8 +205,8 @@ static void fake_wstream__free(git_odb_stream *_stream) ...@@ -205,8 +205,8 @@ static void fake_wstream__free(git_odb_stream *_stream)
{ {
fake_wstream *stream = (fake_wstream *)_stream; fake_wstream *stream = (fake_wstream *)_stream;
free(stream->buffer); git__free(stream->buffer);
free(stream); git__free(stream);
} }
static int init_fake_wstream(git_odb_stream **stream_p, git_odb_backend *backend, size_t size, git_otype type) 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 ...@@ -221,7 +221,7 @@ static int init_fake_wstream(git_odb_stream **stream_p, git_odb_backend *backend
stream->type = type; stream->type = type;
stream->buffer = git__malloc(size); stream->buffer = git__malloc(size);
if (stream->buffer == NULL) { if (stream->buffer == NULL) {
free(stream); git__free(stream);
return GIT_ENOMEM; return GIT_ENOMEM;
} }
...@@ -265,12 +265,12 @@ int git_odb_new(git_odb **out) ...@@ -265,12 +265,12 @@ int git_odb_new(git_odb **out)
error = git_cache_init(&db->cache, GIT_DEFAULT_CACHE_SIZE, &free_odb_object); error = git_cache_init(&db->cache, GIT_DEFAULT_CACHE_SIZE, &free_odb_object);
if (error < GIT_SUCCESS) { if (error < GIT_SUCCESS) {
free(db); git__free(db);
return git__rethrow(error, "Failed to create object database"); return git__rethrow(error, "Failed to create object database");
} }
if ((error = git_vector_init(&db->backends, 4, backend_sort_cmp)) < GIT_SUCCESS) { 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"); 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 ...@@ -296,7 +296,7 @@ static int add_backend_internal(git_odb *odb, git_odb_backend *backend, int prio
internal->is_alternate = is_alternate; internal->is_alternate = is_alternate;
if (git_vector_insert(&odb->backends, internal) < 0) { if (git_vector_insert(&odb->backends, internal) < 0) {
free(internal); git__free(internal);
return GIT_ENOMEM; return GIT_ENOMEM;
} }
...@@ -421,14 +421,14 @@ void git_odb_close(git_odb *db) ...@@ -421,14 +421,14 @@ void git_odb_close(git_odb *db)
git_odb_backend *backend = internal->backend; git_odb_backend *backend = internal->backend;
if (backend->free) backend->free(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_vector_free(&db->backends);
git_cache_free(&db->cache); git_cache_free(&db->cache);
free(db); git__free(db);
} }
int git_odb_exists(git_odb *db, const git_oid *id) int git_odb_exists(git_odb *db, const git_oid *id)
......
...@@ -277,7 +277,7 @@ static void *inflate_tail(z_stream *s, void *hb, size_t used, obj_hdr *hdr) ...@@ -277,7 +277,7 @@ static void *inflate_tail(z_stream *s, void *hb, size_t used, obj_hdr *hdr)
else { else {
set_stream_output(s, buf + used, hdr->size - used); set_stream_output(s, buf + used, hdr->size - used);
if (finish_inflate(s)) { if (finish_inflate(s)) {
free(buf); git__free(buf);
return NULL; return NULL;
} }
} }
...@@ -317,7 +317,7 @@ static int inflate_packlike_loose_disk_obj(git_rawobj *out, git_fbuffer *obj) ...@@ -317,7 +317,7 @@ static int inflate_packlike_loose_disk_obj(git_rawobj *out, git_fbuffer *obj)
in = ((unsigned char *)obj->data) + used; in = ((unsigned char *)obj->data) + used;
len = obj->len - used; len = obj->len - used;
if (inflate_buffer(in, len, buf, hdr.size)) { 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"); return git__throw(GIT_ERROR, "Failed to inflate loose object. Could not inflate buffer");
} }
buf[hdr.size] = '\0'; buf[hdr.size] = '\0';
...@@ -686,7 +686,7 @@ static void loose_backend__stream_free(git_odb_stream *_stream) ...@@ -686,7 +686,7 @@ static void loose_backend__stream_free(git_odb_stream *_stream)
if (!stream->finished) if (!stream->finished)
git_filebuf_cleanup(&stream->fbuf); 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) 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 *_ ...@@ -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)); (backend->object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT));
if (error < GIT_SUCCESS) { if (error < GIT_SUCCESS) {
free(stream); git__free(stream);
return git__rethrow(error, "Failed to create loose backend stream"); return git__rethrow(error, "Failed to create loose backend stream");
} }
error = stream->stream.write((git_odb_stream *)stream, hdr, hdrlen); error = stream->stream.write((git_odb_stream *)stream, hdr, hdrlen);
if (error < GIT_SUCCESS) { if (error < GIT_SUCCESS) {
git_filebuf_cleanup(&stream->fbuf); git_filebuf_cleanup(&stream->fbuf);
free(stream); git__free(stream);
return git__rethrow(error, "Failed to create loose backend stream"); return git__rethrow(error, "Failed to create loose backend stream");
} }
...@@ -803,8 +803,8 @@ static void loose_backend__free(git_odb_backend *_backend) ...@@ -803,8 +803,8 @@ static void loose_backend__free(git_odb_backend *_backend)
assert(_backend); assert(_backend);
backend = (loose_backend *)_backend; backend = (loose_backend *)_backend;
free(backend->objects_dir); git__free(backend->objects_dir);
free(backend); git__free(backend);
} }
int git_odb_backend_loose( int git_odb_backend_loose(
...@@ -821,7 +821,7 @@ int git_odb_backend_loose( ...@@ -821,7 +821,7 @@ int git_odb_backend_loose(
backend->objects_dir = git__strdup(objects_dir); backend->objects_dir = git__strdup(objects_dir);
if (backend->objects_dir == NULL) { if (backend->objects_dir == NULL) {
free(backend); git__free(backend);
return GIT_ENOMEM; return GIT_ENOMEM;
} }
......
...@@ -231,7 +231,7 @@ static int packfile_load__cb(void *_data, char *path) ...@@ -231,7 +231,7 @@ static int packfile_load__cb(void *_data, char *path)
return git__rethrow(error, "Failed to load packfile"); return git__rethrow(error, "Failed to load packfile");
if (git_vector_insert(&backend->packs, pack) < GIT_SUCCESS) { if (git_vector_insert(&backend->packs, pack) < GIT_SUCCESS) {
free(pack); git__free(pack);
return GIT_ENOMEM; return GIT_ENOMEM;
} }
...@@ -445,8 +445,8 @@ static void pack_backend__free(git_odb_backend *_backend) ...@@ -445,8 +445,8 @@ static void pack_backend__free(git_odb_backend *_backend)
} }
git_vector_free(&backend->packs); git_vector_free(&backend->packs);
free(backend->pack_folder); git__free(backend->pack_folder);
free(backend); git__free(backend);
} }
int git_odb_backend_pack(git_odb_backend **backend_out, const char *objects_dir) 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) ...@@ -459,7 +459,7 @@ int git_odb_backend_pack(git_odb_backend **backend_out, const char *objects_dir)
return GIT_ENOMEM; return GIT_ENOMEM;
if (git_vector_init(&backend->packs, 8, packfile_sort__cb) < GIT_SUCCESS) { if (git_vector_init(&backend->packs, 8, packfile_sort__cb) < GIT_SUCCESS) {
free(backend); git__free(backend);
return GIT_ENOMEM; return GIT_ENOMEM;
} }
...@@ -469,7 +469,7 @@ int git_odb_backend_pack(git_odb_backend **backend_out, const char *objects_dir) ...@@ -469,7 +469,7 @@ int git_odb_backend_pack(git_odb_backend **backend_out, const char *objects_dir)
backend->pack_folder_mtime = 0; backend->pack_folder_mtime = 0;
if (backend->pack_folder == NULL) { if (backend->pack_folder == NULL) {
free(backend); git__free(backend);
return GIT_ENOMEM; return GIT_ENOMEM;
} }
} }
......
...@@ -223,7 +223,7 @@ struct git_oid_shorten { ...@@ -223,7 +223,7 @@ struct git_oid_shorten {
static int resize_trie(git_oid_shorten *self, size_t new_size) 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) if (self->nodes == NULL)
return GIT_ENOMEM; return GIT_ENOMEM;
...@@ -270,7 +270,7 @@ git_oid_shorten *git_oid_shorten_new(size_t min_length) ...@@ -270,7 +270,7 @@ git_oid_shorten *git_oid_shorten_new(size_t min_length)
memset(os, 0x0, sizeof(git_oid_shorten)); memset(os, 0x0, sizeof(git_oid_shorten));
if (resize_trie(os, 16) < GIT_SUCCESS) { if (resize_trie(os, 16) < GIT_SUCCESS) {
free(os); git__free(os);
return NULL; return NULL;
} }
...@@ -282,8 +282,8 @@ git_oid_shorten *git_oid_shorten_new(size_t min_length) ...@@ -282,8 +282,8 @@ git_oid_shorten *git_oid_shorten_new(size_t min_length)
void git_oid_shorten_free(git_oid_shorten *os) void git_oid_shorten_free(git_oid_shorten *os)
{ {
free(os->nodes); git__free(os->nodes);
free(os); git__free(os);
} }
......
...@@ -181,7 +181,7 @@ static int pack_index_open(struct git_pack_file *p) ...@@ -181,7 +181,7 @@ static int pack_index_open(struct git_pack_file *p)
strcpy(idx_name + strlen(idx_name) - strlen(".pack"), ".idx"); strcpy(idx_name + strlen(idx_name) - strlen(".pack"), ".idx");
error = pack_index_check(idx_name, p); 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"); return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to open index");
} }
...@@ -297,7 +297,7 @@ static int packfile_unpack_delta( ...@@ -297,7 +297,7 @@ static int packfile_unpack_delta(
error = packfile_unpack_compressed(&delta, p, w_curs, curpos, delta_size, delta_type); error = packfile_unpack_compressed(&delta, p, w_curs, curpos, delta_size, delta_type);
if (error < GIT_SUCCESS) { if (error < GIT_SUCCESS) {
free(base.data); git__free(base.data);
return git__rethrow(error, "Corrupted delta"); return git__rethrow(error, "Corrupted delta");
} }
...@@ -306,8 +306,8 @@ static int packfile_unpack_delta( ...@@ -306,8 +306,8 @@ static int packfile_unpack_delta(
base.data, base.len, base.data, base.len,
delta.data, delta.len); delta.data, delta.len);
free(base.data); git__free(base.data);
free(delta.data); git__free(delta.data);
/* TODO: we might want to cache this shit. eventually */ /* TODO: we might want to cache this shit. eventually */
//add_delta_base_cache(p, base_offset, base, base_size, *type); //add_delta_base_cache(p, base_offset, base, base_size, *type);
...@@ -390,7 +390,7 @@ int packfile_unpack_compressed( ...@@ -390,7 +390,7 @@ int packfile_unpack_compressed(
st = inflateInit(&stream); st = inflateInit(&stream);
if (st != Z_OK) { if (st != Z_OK) {
free(buffer); git__free(buffer);
return git__throw(GIT_EZLIB, "Error in zlib"); return git__throw(GIT_EZLIB, "Error in zlib");
} }
...@@ -408,7 +408,7 @@ int packfile_unpack_compressed( ...@@ -408,7 +408,7 @@ int packfile_unpack_compressed(
inflateEnd(&stream); inflateEnd(&stream);
if ((st != Z_STREAM_END) || stream.total_out != size) { if ((st != Z_STREAM_END) || stream.total_out != size) {
free(buffer); git__free(buffer);
return git__throw(GIT_EZLIB, "Error in zlib"); return git__throw(GIT_EZLIB, "Error in zlib");
} }
...@@ -504,8 +504,8 @@ void packfile_free(struct git_pack_file *p) ...@@ -504,8 +504,8 @@ void packfile_free(struct git_pack_file *p)
pack_index_free(p); pack_index_free(p);
free(p->bad_object_sha1); git__free(p->bad_object_sha1);
free(p); git__free(p);
} }
static int packfile_open(struct git_pack_file *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) ...@@ -598,7 +598,7 @@ int git_packfile_check(struct git_pack_file **pack_out, const char *path)
*/ */
path_len -= strlen(".idx"); path_len -= strlen(".idx");
if (path_len < 1) { if (path_len < 1) {
free(p); git__free(p);
return git__throw(GIT_ENOTFOUND, "Failed to check packfile. Wrong path name"); 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) ...@@ -610,7 +610,7 @@ int git_packfile_check(struct git_pack_file **pack_out, const char *path)
strcpy(p->pack_name + path_len, ".pack"); strcpy(p->pack_name + path_len, ".pack");
if (p_stat(p->pack_name, &st) < GIT_SUCCESS || !S_ISREG(st.st_mode)) { 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"); return git__throw(GIT_ENOTFOUND, "Failed to check packfile. File not found");
} }
......
...@@ -144,7 +144,7 @@ char *git_path_dirname(const char *path) ...@@ -144,7 +144,7 @@ char *git_path_dirname(const char *path)
return NULL; return NULL;
if (git_path_dirname_r(dname, len, path) < GIT_SUCCESS) { if (git_path_dirname_r(dname, len, path) < GIT_SUCCESS) {
free(dname); git__free(dname);
return NULL; return NULL;
} }
...@@ -162,7 +162,7 @@ char *git_path_basename(const char *path) ...@@ -162,7 +162,7 @@ char *git_path_basename(const char *path)
return NULL; return NULL;
if (git_path_basename_r(bname, len, path) < GIT_SUCCESS) { if (git_path_basename_r(bname, len, path) < GIT_SUCCESS) {
free(bname); git__free(bname);
return NULL; return NULL;
} }
......
...@@ -149,7 +149,7 @@ static int ref_pkt(git_pkt **out, const char *line, size_t len) ...@@ -149,7 +149,7 @@ static int ref_pkt(git_pkt **out, const char *line, size_t len)
out: out:
if (error < GIT_SUCCESS) if (error < GIT_SUCCESS)
free(pkt); git__free(pkt);
else else
*out = (git_pkt *)pkt; *out = (git_pkt *)pkt;
...@@ -260,10 +260,10 @@ void git_pkt_free(git_pkt *pkt) ...@@ -260,10 +260,10 @@ void git_pkt_free(git_pkt *pkt)
{ {
if(pkt->type == GIT_PKT_REF) { if(pkt->type == GIT_PKT_REF) {
git_pkt_ref *p = (git_pkt_ref *) pkt; 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) int git_pkt_buffer_flush(git_buf *buf)
......
...@@ -17,7 +17,7 @@ int git_pqueue_init(git_pqueue *q, size_t n, git_pqueue_cmp cmppri) ...@@ -17,7 +17,7 @@ int git_pqueue_init(git_pqueue *q, size_t n, git_pqueue_cmp cmppri)
assert(q); assert(q);
/* Need to allocate n+1 elements since element 0 isn't used. */ /* 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; return GIT_ENOMEM;
q->size = 1; q->size = 1;
...@@ -30,7 +30,7 @@ int git_pqueue_init(git_pqueue *q, size_t n, git_pqueue_cmp cmppri) ...@@ -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) void git_pqueue_free(git_pqueue *q)
{ {
free(q->d); git__free(q->d);
q->d = NULL; q->d = NULL;
} }
...@@ -102,7 +102,7 @@ int git_pqueue_insert(git_pqueue *q, void *d) ...@@ -102,7 +102,7 @@ int git_pqueue_insert(git_pqueue *q, void *d)
/* allocate more memory if necessary */ /* allocate more memory if necessary */
if (q->size >= q->avail) { if (q->size >= q->avail) {
newsize = q->size + q->step; 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; return GIT_ENOMEM;
q->d = tmp; q->d = tmp;
......
...@@ -25,8 +25,8 @@ static int reflog_init(git_reflog **reflog, git_reference *ref) ...@@ -25,8 +25,8 @@ static int reflog_init(git_reflog **reflog, git_reference *ref)
log->ref_name = git__strdup(ref->name); log->ref_name = git__strdup(ref->name);
if (git_vector_init(&log->entries, 0, NULL) < 0) { if (git_vector_init(&log->entries, 0, NULL) < 0) {
free(log->ref_name); git__free(log->ref_name);
free(log); git__free(log);
return GIT_ENOMEM; return GIT_ENOMEM;
} }
...@@ -86,8 +86,8 @@ static int reflog_parse(git_reflog *log, const char *buf, size_t buf_size) ...@@ -86,8 +86,8 @@ static int reflog_parse(git_reflog *log, const char *buf, size_t buf_size)
#define seek_forward(_increase) { \ #define seek_forward(_increase) { \
if (_increase >= buf_size) { \ if (_increase >= buf_size) { \
if (entry->committer) \ if (entry->committer) \
free(entry->committer); \ git__free(entry->committer); \
free(entry); \ git__free(entry); \
return git__throw(GIT_ERROR, "Failed to seek forward. Buffer size exceeded"); \ return git__throw(GIT_ERROR, "Failed to seek forward. Buffer size exceeded"); \
} \ } \
buf += _increase; \ buf += _increase; \
...@@ -101,13 +101,13 @@ static int reflog_parse(git_reflog *log, const char *buf, size_t buf_size) ...@@ -101,13 +101,13 @@ static int reflog_parse(git_reflog *log, const char *buf, size_t buf_size)
entry->committer = NULL; entry->committer = NULL;
if (git_oid_fromstrn(&entry->oid_old, buf, GIT_OID_HEXSZ) < GIT_SUCCESS) { if (git_oid_fromstrn(&entry->oid_old, buf, GIT_OID_HEXSZ) < GIT_SUCCESS) {
free(entry); git__free(entry);
return GIT_ERROR; return GIT_ERROR;
} }
seek_forward(GIT_OID_HEXSZ + 1); seek_forward(GIT_OID_HEXSZ + 1);
if (git_oid_fromstrn(&entry->oid_cur, buf, GIT_OID_HEXSZ) < GIT_SUCCESS) { if (git_oid_fromstrn(&entry->oid_cur, buf, GIT_OID_HEXSZ) < GIT_SUCCESS) {
free(entry); git__free(entry);
return GIT_ERROR; return GIT_ERROR;
} }
seek_forward(GIT_OID_HEXSZ + 1); seek_forward(GIT_OID_HEXSZ + 1);
...@@ -120,13 +120,13 @@ static int reflog_parse(git_reflog *log, const char *buf, size_t buf_size) ...@@ -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)); entry->committer = git__malloc(sizeof(git_signature));
if (entry->committer == NULL) { if (entry->committer == NULL) {
free(entry); git__free(entry);
return GIT_ENOMEM; return GIT_ENOMEM;
} }
if ((error = git_signature__parse(entry->committer, &ptr, buf + 1, NULL, *buf)) < GIT_SUCCESS) { if ((error = git_signature__parse(entry->committer, &ptr, buf + 1, NULL, *buf)) < GIT_SUCCESS) {
free(entry->committer); git__free(entry->committer);
free(entry); git__free(entry);
return git__rethrow(error, "Failed to parse reflog. Could not parse signature"); return git__rethrow(error, "Failed to parse reflog. Could not parse signature");
} }
...@@ -164,13 +164,13 @@ void git_reflog_free(git_reflog *reflog) ...@@ -164,13 +164,13 @@ void git_reflog_free(git_reflog *reflog)
git_signature_free(entry->committer); git_signature_free(entry->committer);
free(entry->msg); git__free(entry->msg);
free(entry); git__free(entry);
} }
git_vector_free(&reflog->entries); git_vector_free(&reflog->entries);
free(reflog->ref_name); git__free(reflog->ref_name);
free(reflog); git__free(reflog);
} }
int git_reflog_read(git_reflog **reflog, git_reference *ref) int git_reflog_read(git_reflog **reflog, git_reference *ref)
......
...@@ -77,12 +77,12 @@ static void reference_free(git_reference *reference) ...@@ -77,12 +77,12 @@ static void reference_free(git_reference *reference)
return; return;
if (reference->name) if (reference->name)
free(reference->name); git__free(reference->name);
if (reference->type == GIT_REF_SYMBOLIC) 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( static int reference_create(
...@@ -212,7 +212,7 @@ static int loose_parse_symbolic(git_reference *ref, git_fbuffer *file_content) ...@@ -212,7 +212,7 @@ static int loose_parse_symbolic(git_reference *ref, git_fbuffer *file_content)
refname_start += header_len; refname_start += header_len;
free(ref_sym->target); git__free(ref_sym->target);
ref_sym->target = git__strdup(refname_start); ref_sym->target = git__strdup(refname_start);
if (ref_sym->target == NULL) if (ref_sym->target == NULL)
return GIT_ENOMEM; return GIT_ENOMEM;
...@@ -1203,7 +1203,7 @@ int git_reference_set_oid(git_reference *ref, const git_oid *id) ...@@ -1203,7 +1203,7 @@ int git_reference_set_oid(git_reference *ref, const git_oid *id)
ref_old->ref.name = git__strdup(ref->name); ref_old->ref.name = git__strdup(ref->name);
if (ref_old->ref.name == NULL) { if (ref_old->ref.name == NULL) {
free(ref_old); git__free(ref_old);
return GIT_ENOMEM; return GIT_ENOMEM;
} }
} }
...@@ -1252,7 +1252,7 @@ int git_reference_set_target(git_reference *ref, const char *target) ...@@ -1252,7 +1252,7 @@ int git_reference_set_target(git_reference *ref, const char *target)
ref_sym = (reference_symbolic *)ref; ref_sym = (reference_symbolic *)ref;
free(ref_sym->target); git__free(ref_sym->target);
ref_sym->target = git__strdup(target); ref_sym->target = git__strdup(target);
if (ref_sym->target == NULL) if (ref_sym->target == NULL)
return GIT_ENOMEM; return GIT_ENOMEM;
...@@ -1381,7 +1381,7 @@ int git_reference_rename(git_reference *ref, const char *new_name, int force) ...@@ -1381,7 +1381,7 @@ int git_reference_rename(git_reference *ref, const char *new_name, int force)
goto rollback; goto rollback;
} }
free(ref->name); git__free(ref->name);
ref->name = new_ref->name; ref->name = new_ref->name;
/* /*
...@@ -1408,7 +1408,7 @@ int git_reference_rename(git_reference *ref, const char *new_name, int force) ...@@ -1408,7 +1408,7 @@ int git_reference_rename(git_reference *ref, const char *new_name, int force)
goto rollback; goto rollback;
cleanup: cleanup:
free(old_name); git__free(old_name);
return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to rename reference"); return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to rename reference");
rollback: rollback:
......
...@@ -32,7 +32,7 @@ int git_refspec_parse(git_refspec *refspec, const char *str) ...@@ -32,7 +32,7 @@ int git_refspec_parse(git_refspec *refspec, const char *str)
refspec->dst = git__strdup(delim + 1); refspec->dst = git__strdup(delim + 1);
if (refspec->dst == NULL) { if (refspec->dst == NULL) {
free(refspec->src); git__free(refspec->src);
refspec->src = NULL; refspec->src = NULL;
return GIT_ENOMEM; return GIT_ENOMEM;
} }
......
...@@ -36,7 +36,7 @@ static int refspec_parse(git_refspec *refspec, const char *str) ...@@ -36,7 +36,7 @@ static int refspec_parse(git_refspec *refspec, const char *str)
refspec->dst = git__strdup(delim + 1); refspec->dst = git__strdup(delim + 1);
if (refspec->dst == NULL) { if (refspec->dst == NULL) {
free(refspec->src); git__free(refspec->src);
refspec->src = NULL; refspec->src = NULL;
return GIT_ENOMEM; return GIT_ENOMEM;
} }
...@@ -68,7 +68,7 @@ int git_remote_new(git_remote **out, git_repository *repo, const char *url) ...@@ -68,7 +68,7 @@ int git_remote_new(git_remote **out, git_repository *repo, const char *url)
remote->repo = repo; remote->repo = repo;
remote->url = git__strdup(url); remote->url = git__strdup(url);
if (remote->url == NULL) { if (remote->url == NULL) {
free(remote); git__free(remote);
return GIT_ENOMEM; return GIT_ENOMEM;
} }
...@@ -150,7 +150,7 @@ int git_remote_get(git_remote **out, git_config *cfg, const char *name) ...@@ -150,7 +150,7 @@ int git_remote_get(git_remote **out, git_config *cfg, const char *name)
*out = remote; *out = remote;
cleanup: cleanup:
free(buf); git__free(buf);
if (error < GIT_SUCCESS) if (error < GIT_SUCCESS)
git_remote_free(remote); git_remote_free(remote);
...@@ -260,17 +260,17 @@ void git_remote_free(git_remote *remote) ...@@ -260,17 +260,17 @@ void git_remote_free(git_remote *remote)
if (remote == NULL) if (remote == NULL)
return; return;
free(remote->fetch.src); git__free(remote->fetch.src);
free(remote->fetch.dst); git__free(remote->fetch.dst);
free(remote->push.src); git__free(remote->push.src);
free(remote->push.dst); git__free(remote->push.dst);
free(remote->url); git__free(remote->url);
free(remote->name); git__free(remote->name);
if (remote->transport != NULL) { if (remote->transport != NULL) {
if (remote->transport->connected) if (remote->transport->connected)
remote->transport->close(remote->transport); remote->transport->close(remote->transport);
remote->transport->free(remote->transport); remote->transport->free(remote->transport);
} }
free(remote); git__free(remote);
} }
...@@ -168,12 +168,12 @@ static git_repository *repository_alloc(void) ...@@ -168,12 +168,12 @@ static git_repository *repository_alloc(void)
error = git_cache_init(&repo->objects, GIT_DEFAULT_CACHE_SIZE, &git_object__free); error = git_cache_init(&repo->objects, GIT_DEFAULT_CACHE_SIZE, &git_object__free);
if (error < GIT_SUCCESS) { if (error < GIT_SUCCESS) {
free(repo); git__free(repo);
return NULL; return NULL;
} }
if (git_repository__refcache_init(&repo->references) < GIT_SUCCESS) { if (git_repository__refcache_init(&repo->references) < GIT_SUCCESS) {
free(repo); git__free(repo);
return NULL; return NULL;
} }
...@@ -467,13 +467,13 @@ static int read_gitfile(char *path_out, const char *file_path, const char *base_ ...@@ -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) static void git_repository__free_dirs(git_repository *repo)
{ {
free(repo->path_workdir); git__free(repo->path_workdir);
repo->path_workdir = NULL; repo->path_workdir = NULL;
free(repo->path_index); git__free(repo->path_index);
repo->path_index = NULL; repo->path_index = NULL;
free(repo->path_repository); git__free(repo->path_repository);
repo->path_repository = NULL; repo->path_repository = NULL;
free(repo->path_odb); git__free(repo->path_odb);
repo->path_odb = NULL; repo->path_odb = NULL;
} }
...@@ -489,7 +489,7 @@ void git_repository_free(git_repository *repo) ...@@ -489,7 +489,7 @@ void git_repository_free(git_repository *repo)
if (repo->db != NULL) if (repo->db != NULL)
git_odb_close(repo->db); 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) int git_repository_discover(char *repository_path, size_t size, const char *start_path, int across_fs, const char *ceiling_dirs)
......
...@@ -68,7 +68,7 @@ static void commit_list_free(commit_list **list_p) ...@@ -68,7 +68,7 @@ static void commit_list_free(commit_list **list_p)
while (list) { while (list) {
commit_list *temp = list; commit_list *temp = list;
list = temp->next; list = temp->next;
free(temp); git__free(temp);
} }
*list_p = NULL; *list_p = NULL;
...@@ -81,7 +81,7 @@ static commit_object *commit_list_pop(commit_list **stack) ...@@ -81,7 +81,7 @@ static commit_object *commit_list_pop(commit_list **stack)
if (top) { if (top) {
*stack = top->next; *stack = top->next;
free(top); git__free(top);
} }
return item; return item;
} }
...@@ -156,7 +156,7 @@ static commit_object *commit_lookup(git_revwalk *walk, const git_oid *oid) ...@@ -156,7 +156,7 @@ static commit_object *commit_lookup(git_revwalk *walk, const git_oid *oid)
git_oid_cpy(&commit->oid, oid); git_oid_cpy(&commit->oid, oid);
if (git_hashtable_insert(walk->commits, &commit->oid, commit) < GIT_SUCCESS) { if (git_hashtable_insert(walk->commits, &commit->oid, commit) < GIT_SUCCESS) {
free(commit); git__free(commit);
return NULL; return NULL;
} }
...@@ -442,7 +442,7 @@ int git_revwalk_new(git_revwalk **revwalk_out, git_repository *repo) ...@@ -442,7 +442,7 @@ int git_revwalk_new(git_revwalk **revwalk_out, git_repository *repo)
(git_hash_keyeq_ptr)git_oid_cmp); (git_hash_keyeq_ptr)git_oid_cmp);
if (walk->commits == NULL) { if (walk->commits == NULL) {
free(walk); git__free(walk);
return GIT_ENOMEM; return GIT_ENOMEM;
} }
...@@ -475,17 +475,17 @@ void git_revwalk_free(git_revwalk *walk) ...@@ -475,17 +475,17 @@ void git_revwalk_free(git_revwalk *walk)
* make sure it's being free'd */ * make sure it's being free'd */
GIT_HASHTABLE_FOREACH(walk->commits, _unused, commit, { GIT_HASHTABLE_FOREACH(walk->commits, _unused, commit, {
if (commit->out_degree > PARENTS_PER_COMMIT) if (commit->out_degree > PARENTS_PER_COMMIT)
free(commit->parents); git__free(commit->parents);
}); });
git_hashtable_free(walk->commits); git_hashtable_free(walk->commits);
git_pqueue_free(&walk->iterator_time); git_pqueue_free(&walk->iterator_time);
for (i = 0; i < walk->memory_alloc.length; ++i) 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); git_vector_free(&walk->memory_alloc);
free(walk); git__free(walk);
} }
git_repository *git_revwalk_repository(git_revwalk *walk) git_repository *git_revwalk_repository(git_revwalk *walk)
......
...@@ -15,9 +15,9 @@ void git_signature_free(git_signature *sig) ...@@ -15,9 +15,9 @@ void git_signature_free(git_signature *sig)
if (sig == NULL) if (sig == NULL)
return; return;
free(sig->name); git__free(sig->name);
free(sig->email); git__free(sig->email);
free(sig); git__free(sig);
} }
static const char *skip_leading_spaces(const char *buffer, const char *buffer_end) static const char *skip_leading_spaces(const char *buffer, const char *buffer_end)
......
...@@ -229,7 +229,7 @@ static int store_if_changed(struct status_st *st, struct status_entry *e) ...@@ -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); 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) { if (e->status_flags == GIT_STATUS_CURRENT) {
free(e); git__free(e);
return GIT_SUCCESS; return GIT_SUCCESS;
} }
...@@ -446,7 +446,7 @@ int git_status_foreach(git_repository *repo, int (*callback)(const char *, unsig ...@@ -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"); error = git__rethrow(error, "Failed to determine statuses. User callback failed");
} }
free(e); git__free(e);
} }
exit: exit:
...@@ -550,7 +550,7 @@ int git_status_file(unsigned int *status_flags, git_repository *repo, const char ...@@ -550,7 +550,7 @@ int git_status_file(unsigned int *status_flags, git_repository *repo, const char
exit: exit:
git_tree_close(tree); git_tree_close(tree);
free(e); git__free(e);
return error; return error;
} }
...@@ -606,7 +606,7 @@ static int alphasorted_dirent_cb(void *state, char *full_path) ...@@ -606,7 +606,7 @@ static int alphasorted_dirent_cb(void *state, char *full_path)
return GIT_ENOMEM; return GIT_ENOMEM;
if (git_vector_insert(entry_names, entry) < GIT_SUCCESS) { if (git_vector_insert(entry_names, entry) < GIT_SUCCESS) {
free(entry); git__free(entry);
return GIT_ENOMEM; return GIT_ENOMEM;
} }
...@@ -639,7 +639,7 @@ static int alphasorted_futils_direach( ...@@ -639,7 +639,7 @@ static int alphasorted_futils_direach(
error = fn(arg, entry->path); error = fn(arg, entry->path);
} }
free(entry); git__free(entry);
} }
git_vector_free(&entry_names); git_vector_free(&entry_names);
......
...@@ -16,9 +16,9 @@ ...@@ -16,9 +16,9 @@
void git_tag__free(git_tag *tag) void git_tag__free(git_tag *tag)
{ {
git_signature_free(tag->tagger); git_signature_free(tag->tagger);
free(tag->message); git__free(tag->message);
free(tag->tag_name); git__free(tag->tag_name);
free(tag); git__free(tag);
} }
const git_oid *git_tag_id(git_tag *c) 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 ...@@ -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); error = git_reference_set_oid(new_ref, oid);
git_signature_free(tag.tagger); git_signature_free(tag.tagger);
free(tag.tag_name); git__free(tag.tag_name);
free(tag.message); git__free(tag.message);
return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to create tag"); return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to create tag");
} }
......
...@@ -109,8 +109,8 @@ static int do_connect(transport_git *t, const char *url) ...@@ -109,8 +109,8 @@ static int do_connect(transport_git *t, const char *url)
error = send_request(s, NULL, url); error = send_request(s, NULL, url);
t->socket = s; t->socket = s;
free(host); git__free(host);
free(port); git__free(port);
if (error < GIT_SUCCESS && s > 0) if (error < GIT_SUCCESS && s > 0)
close(s); close(s);
...@@ -357,11 +357,11 @@ static int git_negotiate_fetch(git_transport *transport, git_repository *repo, g ...@@ -357,11 +357,11 @@ static int git_negotiate_fetch(git_transport *transport, git_repository *repo, g
gitno_consume(buf, line_end); gitno_consume(buf, line_end);
if (pkt->type == GIT_PKT_ACK) { if (pkt->type == GIT_PKT_ACK) {
free(pkt); git__free(pkt);
error = GIT_SUCCESS; error = GIT_SUCCESS;
goto done; goto done;
} else if (pkt->type == GIT_PKT_NAK) { } else if (pkt->type == GIT_PKT_NAK) {
free(pkt); git__free(pkt);
break; break;
} else { } else {
error = git__throw(GIT_ERROR, "Got unexpected pkt type"); 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 ...@@ -424,12 +424,12 @@ static int git_download_pack(char **out, git_transport *transport, git_repositor
return error; return error;
if (pkt->type == GIT_PKT_PACK) { if (pkt->type == GIT_PKT_PACK) {
free(pkt); git__free(pkt);
return git_fetch__download_pack(out, buf->data, buf->offset, t->socket, repo); return git_fetch__download_pack(out, buf->data, buf->offset, t->socket, repo);
} }
/* For now we don't care about anything */ /* For now we don't care about anything */
free(pkt); git__free(pkt);
gitno_consume(buf, line_end); gitno_consume(buf, line_end);
} }
...@@ -475,9 +475,9 @@ static void git_free(git_transport *transport) ...@@ -475,9 +475,9 @@ static void git_free(git_transport *transport)
} }
git_vector_free(refs); git_vector_free(refs);
free(t->heads); git__free(t->heads);
free(t->parent.url); git__free(t->parent.url);
free(t); git__free(t);
} }
int git_transport_git(git_transport **out) int git_transport_git(git_transport **out)
......
...@@ -389,18 +389,18 @@ static int on_body_parse_response(http_parser *parser, const char *str, size_t l ...@@ -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); git_buf_consume(buf, line_end);
if (pkt->type == GIT_PKT_PACK) { if (pkt->type == GIT_PKT_PACK) {
free(pkt); git__free(pkt);
t->pack_ready = 1; t->pack_ready = 1;
return 0; return 0;
} }
if (pkt->type == GIT_PKT_NAK) { if (pkt->type == GIT_PKT_NAK) {
free(pkt); git__free(pkt);
return 0; return 0;
} }
if (pkt->type != GIT_PKT_ACK) { if (pkt->type != GIT_PKT_ACK) {
free(pkt); git__free(pkt);
continue; continue;
} }
...@@ -749,13 +749,13 @@ static void http_free(git_transport *transport) ...@@ -749,13 +749,13 @@ static void http_free(git_transport *transport)
} }
git_vector_free(common); git_vector_free(common);
git_buf_free(&t->buf); git_buf_free(&t->buf);
free(t->heads); git__free(t->heads);
free(t->content_type); git__free(t->content_type);
free(t->host); git__free(t->host);
free(t->port); git__free(t->port);
free(t->service); git__free(t->service);
free(t->parent.url); git__free(t->parent.url);
free(t); git__free(t);
} }
int git_transport_http(git_transport **out) int git_transport_http(git_transport **out)
......
...@@ -113,8 +113,8 @@ static int add_ref(const char *name, git_repository *repo, git_vector *vec) ...@@ -113,8 +113,8 @@ static int add_ref(const char *name, git_repository *repo, git_vector *vec)
out: out:
git_object_close(obj); git_object_close(obj);
if (error < GIT_SUCCESS) { if (error < GIT_SUCCESS) {
free(head->name); git__free(head->name);
free(head); git__free(head);
} }
return error; return error;
} }
...@@ -190,16 +190,16 @@ static void local_free(git_transport *transport) ...@@ -190,16 +190,16 @@ static void local_free(git_transport *transport)
if (t->refs != NULL) { if (t->refs != NULL) {
git_vector_foreach (vec, i, h) { git_vector_foreach (vec, i, h) {
free(h->name); git__free(h->name);
free(h); git__free(h);
} }
git_vector_free(vec); git_vector_free(vec);
free(vec); git__free(vec);
} }
git_repository_free(t->repo); git_repository_free(t->repo);
free(t->parent.url); git__free(t->parent.url);
free(t); git__free(t);
} }
/************** /**************
......
...@@ -196,6 +196,6 @@ void git_tree_cache_free(git_tree_cache *tree) ...@@ -196,6 +196,6 @@ void git_tree_cache_free(git_tree_cache *tree)
for (i = 0; i < tree->children_count; ++i) for (i = 0; i < tree->children_count; ++i)
git_tree_cache_free(tree->children[i]); git_tree_cache_free(tree->children[i]);
free(tree->children); git__free(tree->children);
free(tree); git__free(tree);
} }
...@@ -130,12 +130,12 @@ void git_tree__free(git_tree *tree) ...@@ -130,12 +130,12 @@ void git_tree__free(git_tree *tree)
git_tree_entry *e; git_tree_entry *e;
e = git_vector_get(&tree->entries, i); e = git_vector_get(&tree->entries, i);
free(e->filename); git__free(e->filename);
free(e); git__free(e);
} }
git_vector_free(&tree->entries); git_vector_free(&tree->entries);
free(tree); git__free(tree);
} }
const git_oid *git_tree_id(git_tree *c) 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 ...@@ -378,7 +378,7 @@ static int write_tree(git_oid *oid, git_index *index, const char *dirname, unsig
last_comp = subdir; last_comp = subdir;
} }
error = append_entry(bld, last_comp, &sub_oid, S_IFDIR); error = append_entry(bld, last_comp, &sub_oid, S_IFDIR);
free(subdir); git__free(subdir);
if (error < GIT_SUCCESS) { if (error < GIT_SUCCESS) {
error = git__rethrow(error, "Failed to insert dir"); error = git__rethrow(error, "Failed to insert dir");
goto cleanup; goto cleanup;
...@@ -441,7 +441,7 @@ int git_treebuilder_create(git_treebuilder **builder_p, const git_tree *source) ...@@ -441,7 +441,7 @@ int git_treebuilder_create(git_treebuilder **builder_p, const git_tree *source)
source_entries = source->entries.length; source_entries = source->entries.length;
if (git_vector_init(&bld->entries, source_entries, entry_sort_cmp) < GIT_SUCCESS) { if (git_vector_init(&bld->entries, source_entries, entry_sort_cmp) < GIT_SUCCESS) {
free(bld); git__free(bld);
return GIT_ENOMEM; return GIT_ENOMEM;
} }
...@@ -596,8 +596,8 @@ void git_treebuilder_clear(git_treebuilder *bld) ...@@ -596,8 +596,8 @@ void git_treebuilder_clear(git_treebuilder *bld)
for (i = 0; i < bld->entries.length; ++i) { for (i = 0; i < bld->entries.length; ++i) {
git_tree_entry *e = bld->entries.contents[i]; git_tree_entry *e = bld->entries.contents[i];
free(e->filename); git__free(e->filename);
free(e); git__free(e);
} }
git_vector_clear(&bld->entries); git_vector_clear(&bld->entries);
...@@ -607,7 +607,7 @@ void git_treebuilder_free(git_treebuilder *bld) ...@@ -607,7 +607,7 @@ void git_treebuilder_free(git_treebuilder *bld)
{ {
git_treebuilder_clear(bld); git_treebuilder_clear(bld);
git_vector_free(&bld->entries); 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) static int tree_frompath(git_tree **parent_out, git_tree *root, const char *treeentry_path, int offset)
......
...@@ -178,7 +178,7 @@ static int check_invariant(struct tsort_run *stack, int stack_curr) ...@@ -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) static int resize(struct tsort_store *store, size_t new_size)
{ {
if (store->alloc < 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 * 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, ...@@ -319,7 +319,7 @@ static ssize_t collapse(void **dst, struct tsort_run *stack, ssize_t stack_curr,
stack_curr--; \ stack_curr--; \
} \ } \
if (store->storage != NULL) {\ if (store->storage != NULL) {\
free(store->storage);\ git__free(store->storage);\
store->storage = NULL;\ store->storage = NULL;\
}\ }\
return;\ return;\
......
...@@ -26,9 +26,9 @@ void git_strarray_free(git_strarray *array) ...@@ -26,9 +26,9 @@ void git_strarray_free(git_strarray *array)
{ {
size_t i; size_t i;
for (i = 0; i < array->count; ++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) int git__fnmatch(const char *pattern, const char *name, int flags)
......
...@@ -72,6 +72,8 @@ GIT_INLINE(void *) git__realloc(void *ptr, size_t size) ...@@ -72,6 +72,8 @@ GIT_INLINE(void *) git__realloc(void *ptr, size_t size)
return new_ptr; return new_ptr;
} }
#define git__free(ptr) free(ptr)
extern int git__prefixcmp(const char *str, const char *prefix); extern int git__prefixcmp(const char *str, const char *prefix);
extern int git__suffixcmp(const char *str, const char *suffix); extern int git__suffixcmp(const char *str, const char *suffix);
......
...@@ -18,7 +18,7 @@ static int resize_vector(git_vector *v) ...@@ -18,7 +18,7 @@ static int resize_vector(git_vector *v)
if (v->_alloc_size < minimum_size) if (v->_alloc_size < minimum_size)
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) if (v->contents == NULL)
return GIT_ENOMEM; return GIT_ENOMEM;
...@@ -29,7 +29,7 @@ static int resize_vector(git_vector *v) ...@@ -29,7 +29,7 @@ static int resize_vector(git_vector *v)
void git_vector_free(git_vector *v) void git_vector_free(git_vector *v)
{ {
assert(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) int git_vector_init(git_vector *v, unsigned int initial_size, git_vector_cmp cmp)
......
...@@ -39,18 +39,18 @@ git__DIR *git__opendir(const char *dir) ...@@ -39,18 +39,18 @@ git__DIR *git__opendir(const char *dir)
new->dir = git__malloc(strlen(dir)+1); new->dir = git__malloc(strlen(dir)+1);
if (!new->dir) { if (!new->dir) {
free(new); git__free(new);
return NULL; return NULL;
} }
strcpy(new->dir, dir); strcpy(new->dir, dir);
filter_w = gitwin_to_utf16(filter); filter_w = gitwin_to_utf16(filter);
new->h = FindFirstFileW(filter_w, &new->f); new->h = FindFirstFileW(filter_w, &new->f);
free(filter_w); git__free(filter_w);
if (new->h == INVALID_HANDLE_VALUE) { if (new->h == INVALID_HANDLE_VALUE) {
free(new->dir); git__free(new->dir);
free(new); git__free(new);
return NULL; return NULL;
} }
new->first = 1; new->first = 1;
...@@ -93,7 +93,7 @@ void git__rewinddir(git__DIR *d) ...@@ -93,7 +93,7 @@ void git__rewinddir(git__DIR *d)
if (init_filter(filter, sizeof(filter), d->dir)) { if (init_filter(filter, sizeof(filter), d->dir)) {
filter_w = gitwin_to_utf16(filter); filter_w = gitwin_to_utf16(filter);
d->h = FindFirstFileW(filter_w, &d->f); d->h = FindFirstFileW(filter_w, &d->f);
free(filter_w); git__free(filter_w);
if (d->h != INVALID_HANDLE_VALUE) if (d->h != INVALID_HANDLE_VALUE)
d->first = 1; d->first = 1;
...@@ -107,8 +107,8 @@ int git__closedir(git__DIR *d) ...@@ -107,8 +107,8 @@ int git__closedir(git__DIR *d)
if (d->h != INVALID_HANDLE_VALUE) if (d->h != INVALID_HANDLE_VALUE)
FindClose(d->h); FindClose(d->h);
if (d->dir) if (d->dir)
free(d->dir); git__free(d->dir);
free(d); git__free(d);
} }
return 0; return 0;
} }
......
...@@ -26,7 +26,7 @@ GIT_INLINE(int) p_mkdir(const char *path, int GIT_UNUSED(mode)) ...@@ -26,7 +26,7 @@ GIT_INLINE(int) p_mkdir(const char *path, int GIT_UNUSED(mode))
GIT_UNUSED_ARG(mode) GIT_UNUSED_ARG(mode)
free(buf); git__free(buf);
return ret; return ret;
} }
......
...@@ -20,7 +20,7 @@ int p_unlink(const char *path) ...@@ -20,7 +20,7 @@ int p_unlink(const char *path)
buf = gitwin_to_utf16(path); buf = gitwin_to_utf16(path);
_wchmod(buf, 0666); _wchmod(buf, 0666);
ret = _wunlink(buf); ret = _wunlink(buf);
free(buf); git__free(buf);
return ret; return ret;
} }
...@@ -86,11 +86,11 @@ static int do_lstat(const char *file_name, struct stat *buf) ...@@ -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_mtime = filetime_to_time_t(&(fdata.ftLastWriteTime));
buf->st_ctime = filetime_to_time_t(&(fdata.ftCreationTime)); buf->st_ctime = filetime_to_time_t(&(fdata.ftCreationTime));
free(fbuf); git__free(fbuf);
return GIT_SUCCESS; return GIT_SUCCESS;
} }
free(fbuf); git__free(fbuf);
switch (GetLastError()) { switch (GetLastError()) {
case ERROR_ACCESS_DENIED: case ERROR_ACCESS_DENIED:
...@@ -171,7 +171,7 @@ int p_readlink(const char *link, char *target, size_t target_len) ...@@ -171,7 +171,7 @@ int p_readlink(const char *link, char *target, size_t target_len)
FILE_FLAG_BACKUP_SEMANTICS, // normal file FILE_FLAG_BACKUP_SEMANTICS, // normal file
NULL); // no attr. template NULL); // no attr. template
free(link_w); git__free(link_w);
if (hFile == INVALID_HANDLE_VALUE) if (hFile == INVALID_HANDLE_VALUE)
return GIT_EOSERR; return GIT_EOSERR;
...@@ -184,17 +184,17 @@ int p_readlink(const char *link, char *target, size_t target_len) ...@@ -184,17 +184,17 @@ int p_readlink(const char *link, char *target, size_t target_len)
dwRet = pGetFinalPath(hFile, target_w, target_len, 0x0); dwRet = pGetFinalPath(hFile, target_w, target_len, 0x0);
if (dwRet >= target_len) { if (dwRet >= target_len) {
free(target_w); git__free(target_w);
CloseHandle(hFile); CloseHandle(hFile);
return GIT_ENOMEM; return GIT_ENOMEM;
} }
if (!WideCharToMultiByte(CP_UTF8, 0, target_w, -1, target, target_len * sizeof(char), NULL, NULL)) { 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; return GIT_EOSERR;
} }
free(target_w); git__free(target_w);
CloseHandle(hFile); CloseHandle(hFile);
if (dwRet > 4) { if (dwRet > 4) {
...@@ -226,7 +226,7 @@ int p_open(const char *path, int flags) ...@@ -226,7 +226,7 @@ int p_open(const char *path, int flags)
wchar_t* buf = gitwin_to_utf16(path); wchar_t* buf = gitwin_to_utf16(path);
fd = _wopen(buf, flags | _O_BINARY); fd = _wopen(buf, flags | _O_BINARY);
free(buf); git__free(buf);
return fd; return fd;
} }
...@@ -236,7 +236,7 @@ int p_creat(const char *path, int mode) ...@@ -236,7 +236,7 @@ int p_creat(const char *path, int mode)
wchar_t* buf = gitwin_to_utf16(path); wchar_t* buf = gitwin_to_utf16(path);
fd = _wopen(buf, _O_WRONLY | _O_CREAT | _O_TRUNC | _O_BINARY, mode); fd = _wopen(buf, _O_WRONLY | _O_CREAT | _O_TRUNC | _O_BINARY, mode);
free(buf); git__free(buf);
return fd; return fd;
} }
...@@ -246,11 +246,11 @@ int p_getcwd(char *buffer_out, size_t size) ...@@ -246,11 +246,11 @@ int p_getcwd(char *buffer_out, size_t size)
_wgetcwd(buf, (int)size); _wgetcwd(buf, (int)size);
if (!WideCharToMultiByte(CP_UTF8, 0, buf, -1, buffer_out, size, NULL, NULL)) { if (!WideCharToMultiByte(CP_UTF8, 0, buf, -1, buffer_out, size, NULL, NULL)) {
free(buf); git__free(buf);
return GIT_EOSERR; return GIT_EOSERR;
} }
free(buf); git__free(buf);
return GIT_SUCCESS; return GIT_SUCCESS;
} }
...@@ -264,7 +264,7 @@ int p_chdir(const char* path) ...@@ -264,7 +264,7 @@ int p_chdir(const char* path)
wchar_t* buf = gitwin_to_utf16(path); wchar_t* buf = gitwin_to_utf16(path);
int ret = _wchdir(buf); int ret = _wchdir(buf);
free(buf); git__free(buf);
return ret; return ret;
} }
...@@ -273,7 +273,7 @@ int p_chmod(const char* path, int mode) ...@@ -273,7 +273,7 @@ int p_chmod(const char* path, int mode)
wchar_t* buf = gitwin_to_utf16(path); wchar_t* buf = gitwin_to_utf16(path);
int ret = _wchmod(buf, mode); int ret = _wchmod(buf, mode);
free(buf); git__free(buf);
return ret; return ret;
} }
...@@ -282,7 +282,7 @@ int p_rmdir(const char* path) ...@@ -282,7 +282,7 @@ int p_rmdir(const char* path)
wchar_t* buf = gitwin_to_utf16(path); wchar_t* buf = gitwin_to_utf16(path);
int ret = _wrmdir(buf); int ret = _wrmdir(buf);
free(buf); git__free(buf);
return ret; return ret;
} }
...@@ -294,7 +294,7 @@ int p_hide_directory__w32(const char *path) ...@@ -294,7 +294,7 @@ int p_hide_directory__w32(const char *path)
error = SetFileAttributesW(buf, FILE_ATTRIBUTE_HIDDEN) != 0 ? error = SetFileAttributesW(buf, FILE_ATTRIBUTE_HIDDEN) != 0 ?
GIT_SUCCESS : GIT_ERROR; /* MSDN states a "non zero" value indicates a success */ GIT_SUCCESS : GIT_ERROR; /* MSDN states a "non zero" value indicates a success */
free(buf); git__free(buf);
if (error < GIT_SUCCESS) if (error < GIT_SUCCESS)
error = git__throw(GIT_EOSERR, "Failed to hide directory '%s'", path); error = git__throw(GIT_EOSERR, "Failed to hide directory '%s'", path);
...@@ -314,21 +314,21 @@ char *p_realpath(const char *orig_path, char *buffer) ...@@ -314,21 +314,21 @@ char *p_realpath(const char *orig_path, char *buffer)
} }
ret = GetFullPathNameW(orig_path_w, GIT_PATH_MAX, buffer_w, NULL); 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) { if (!ret || ret > GIT_PATH_MAX) {
free(buffer_w); git__free(buffer_w);
if (alloc) free(buffer); if (alloc) git__free(buffer);
return NULL; return NULL;
} }
if (!WideCharToMultiByte(CP_UTF8, 0, buffer_w, -1, buffer, GIT_PATH_MAX, NULL, NULL)) { if (!WideCharToMultiByte(CP_UTF8, 0, buffer_w, -1, buffer, GIT_PATH_MAX, NULL, NULL)) {
free(buffer_w); git__free(buffer_w);
if (alloc) free(buffer); if (alloc) git__free(buffer);
} }
free(buffer_w); git__free(buffer_w);
git_path_mkposix(buffer); git_path_mkposix(buffer);
return buffer; return buffer;
} }
...@@ -384,7 +384,7 @@ int p_access(const char* path, int mode) ...@@ -384,7 +384,7 @@ int p_access(const char* path, int mode)
int ret; int ret;
ret = _waccess(buf, mode); ret = _waccess(buf, mode);
free(buf); git__free(buf);
return ret; return ret;
} }
...@@ -50,7 +50,7 @@ wchar_t* gitwin_to_utf16(const char* str) ...@@ -50,7 +50,7 @@ wchar_t* gitwin_to_utf16(const char* str)
ret = (wchar_t*)git__malloc(cb); ret = (wchar_t*)git__malloc(cb);
if (MultiByteToWideChar(_active_codepage, 0, str, -1, ret, cb) == 0) { if (MultiByteToWideChar(_active_codepage, 0, str, -1, ret, cb) == 0) {
free(ret); git__free(ret);
ret = NULL; ret = NULL;
} }
...@@ -79,7 +79,7 @@ char* gitwin_from_utf16(const wchar_t* str) ...@@ -79,7 +79,7 @@ char* gitwin_from_utf16(const wchar_t* str)
ret = (char*)git__malloc(cb); ret = (char*)git__malloc(cb);
if (WideCharToMultiByte(_active_codepage, 0, str, -1, ret, cb, NULL, NULL) == 0) { if (WideCharToMultiByte(_active_codepage, 0, str, -1, ret, cb, NULL, NULL) == 0) {
free(ret); git__free(ret);
ret = NULL; ret = NULL;
} }
......
...@@ -11,7 +11,7 @@ check_dirname(const char *A, const char *B) ...@@ -11,7 +11,7 @@ check_dirname(const char *A, const char *B)
cl_assert((dir2 = git_path_dirname(A)) != NULL); cl_assert((dir2 = git_path_dirname(A)) != NULL);
cl_assert(strcmp(dir2, B) == 0); cl_assert(strcmp(dir2, B) == 0);
free(dir2); git__free(dir2);
} }
static void static void
...@@ -24,7 +24,7 @@ check_basename(const char *A, const char *B) ...@@ -24,7 +24,7 @@ check_basename(const char *A, const char *B)
cl_assert((base2 = git_path_basename(A)) != NULL); cl_assert((base2 = git_path_basename(A)) != NULL);
cl_assert(strcmp(base2, B) == 0); cl_assert(strcmp(base2, B) == 0);
free(base2); git__free(base2);
} }
static void static void
......
...@@ -59,8 +59,8 @@ void test_core_vector__2(void) ...@@ -59,8 +59,8 @@ void test_core_vector__2(void)
git_vector_free(&x); git_vector_free(&x);
free(ptrs[0]); git__free(ptrs[0]);
free(ptrs[1]); git__free(ptrs[1]);
} }
...@@ -101,7 +101,7 @@ void test_object_raw_compare__compare_allocfmt_oids(void) ...@@ -101,7 +101,7 @@ void test_object_raw_compare__compare_allocfmt_oids(void)
out = git_oid_allocfmt(&in); out = git_oid_allocfmt(&in);
cl_assert(out); cl_assert(out);
cl_assert(strcmp(exp, out) == 0); cl_assert(strcmp(exp, out) == 0);
free(out); git__free(out);
} }
void test_object_raw_compare__compare_pathfmt_oids(void) void test_object_raw_compare__compare_pathfmt_oids(void)
......
...@@ -86,7 +86,7 @@ void test_object_raw_short__oid_shortener_stresstest_git_oid_shorten(void) ...@@ -86,7 +86,7 @@ void test_object_raw_short__oid_shortener_stresstest_git_oid_shorten(void)
/* cleanup */ /* cleanup */
for (i = 0; i < MAX_OIDS; ++i) for (i = 0; i < MAX_OIDS; ++i)
free(oids[i]); git__free(oids[i]);
git_oid_shorten_free(os); git_oid_shorten_free(os);
......
...@@ -99,8 +99,8 @@ BEGIN_TEST(vector2, "remove duplicates") ...@@ -99,8 +99,8 @@ BEGIN_TEST(vector2, "remove duplicates")
must_be_true(x.length == 2); must_be_true(x.length == 2);
git_vector_free(&x); git_vector_free(&x);
free(ptrs[0]); git__free(ptrs[0]);
free(ptrs[1]); git__free(ptrs[1]);
END_TEST END_TEST
...@@ -112,7 +112,7 @@ BEGIN_TEST(path0, "get the dirname of a path") ...@@ -112,7 +112,7 @@ BEGIN_TEST(path0, "get the dirname of a path")
must_be_true(strcmp(dir, B) == 0); \ must_be_true(strcmp(dir, B) == 0); \
must_be_true((dir2 = git_path_dirname(A)) != NULL); \ must_be_true((dir2 = git_path_dirname(A)) != NULL); \
must_be_true(strcmp(dir2, B) == 0); \ must_be_true(strcmp(dir2, B) == 0); \
free(dir2); \ git__free(dir2); \
} }
DIRNAME_TEST(NULL, "."); DIRNAME_TEST(NULL, ".");
...@@ -141,7 +141,7 @@ BEGIN_TEST(path1, "get the base name of a path") ...@@ -141,7 +141,7 @@ BEGIN_TEST(path1, "get the base name of a path")
must_be_true(strcmp(base, B) == 0); \ must_be_true(strcmp(base, B) == 0); \
must_be_true((base2 = git_path_basename(A)) != NULL); \ must_be_true((base2 = git_path_basename(A)) != NULL); \
must_be_true(strcmp(base2, B) == 0); \ must_be_true(strcmp(base2, B) == 0); \
free(base2); \ git__free(base2); \
} }
BASENAME_TEST(NULL, "."); BASENAME_TEST(NULL, ".");
......
...@@ -217,7 +217,7 @@ BEGIN_TEST(oid12, "compare oids (allocate + format)") ...@@ -217,7 +217,7 @@ BEGIN_TEST(oid12, "compare oids (allocate + format)")
out = git_oid_allocfmt(&in); out = git_oid_allocfmt(&in);
must_be_true(out); must_be_true(out);
must_be_true(strcmp(exp, out) == 0); must_be_true(strcmp(exp, out) == 0);
free(out); git__free(out);
END_TEST END_TEST
BEGIN_TEST(oid13, "compare oids (path format)") BEGIN_TEST(oid13, "compare oids (path format)")
...@@ -390,7 +390,7 @@ BEGIN_TEST(oid17, "stress test for the git_oid_shorten object") ...@@ -390,7 +390,7 @@ BEGIN_TEST(oid17, "stress test for the git_oid_shorten object")
/* cleanup */ /* cleanup */
for (i = 0; i < MAX_OIDS; ++i) for (i = 0; i < MAX_OIDS; ++i)
free(oids[i]); git__free(oids[i]);
git_oid_shorten_free(os); git_oid_shorten_free(os);
......
...@@ -162,7 +162,7 @@ BEGIN_TEST(parse1, "parse the signature line in a commit") ...@@ -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(strcmp(_email, person.email) == 0);\
must_be_true(_time == person.when.time);\ must_be_true(_time == person.when.time);\
must_be_true(_offset == person.when.offset);\ 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) { \ #define TEST_SIGNATURE_FAIL(_string, _header) { \
...@@ -170,7 +170,7 @@ BEGIN_TEST(parse1, "parse the signature line in a commit") ...@@ -170,7 +170,7 @@ BEGIN_TEST(parse1, "parse the signature line in a commit")
size_t len = strlen(_string);\ size_t len = strlen(_string);\
git_signature person = {NULL, NULL, {0, 0}}; \ git_signature person = {NULL, NULL, {0, 0}}; \
must_fail(git_signature__parse(&person, &ptr, ptr + len, _header, '\n'));\ 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( TEST_SIGNATURE_PASS(
...@@ -759,7 +759,7 @@ BEGIN_TEST(root0, "create a root commit") ...@@ -759,7 +759,7 @@ BEGIN_TEST(root0, "create a root commit")
must_pass(git_reference_set_target(head, head_old)); must_pass(git_reference_set_target(head, head_old));
must_pass(git_reference_delete(branch)); must_pass(git_reference_delete(branch));
must_pass(remove_loose_object(REPOSITORY_FOLDER, (git_object *)commit)); must_pass(remove_loose_object(REPOSITORY_FOLDER, (git_object *)commit));
free(head_old); git__free(head_old);
git_commit_close(commit); git_commit_close(commit);
git_repository_free(repo); git_repository_free(repo);
END_TEST END_TEST
......
...@@ -103,7 +103,7 @@ BEGIN_TEST(table1, "fill the hashtable with random entries") ...@@ -103,7 +103,7 @@ BEGIN_TEST(table1, "fill the hashtable with random entries")
} }
git_hashtable_free(table); git_hashtable_free(table);
free(objects); git__free(objects);
END_TEST END_TEST
...@@ -145,7 +145,7 @@ BEGIN_TEST(table2, "make sure the table resizes automatically") ...@@ -145,7 +145,7 @@ BEGIN_TEST(table2, "make sure the table resizes automatically")
} }
git_hashtable_free(table); git_hashtable_free(table);
free(objects); git__free(objects);
END_TEST END_TEST
...@@ -179,7 +179,7 @@ BEGIN_TEST(tableit0, "iterate through all the contents of the table") ...@@ -179,7 +179,7 @@ BEGIN_TEST(tableit0, "iterate through all the contents of the table")
must_be_true(objects[i].visited); must_be_true(objects[i].visited);
git_hashtable_free(table); git_hashtable_free(table);
free(objects); git__free(objects);
END_TEST END_TEST
......
...@@ -116,7 +116,7 @@ int remove_loose_object(const char *repository_folder, git_object *object) ...@@ -116,7 +116,7 @@ int remove_loose_object(const char *repository_folder, git_object *object)
return -1; return -1;
} }
free(full_path); git__free(full_path);
return GIT_SUCCESS; return GIT_SUCCESS;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment