Skip to content

Commit

Permalink
Convert usage of git_buf_free to new git_buf_dispose
Browse files Browse the repository at this point in the history
  • Loading branch information
pks-t committed Jun 10, 2018
1 parent 56ffdfc commit ecf4f33
Show file tree
Hide file tree
Showing 231 changed files with 1,057 additions and 1,056 deletions.
2 changes: 1 addition & 1 deletion examples/diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,6 @@ static void diff_print_stats(git_diff *diff, struct opts *o)

fputs(b.ptr, stdout);

git_buf_free(&b);
git_buf_dispose(&b);
git_diff_stats_free(stats);
}
2 changes: 1 addition & 1 deletion examples/remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ int main(int argc, char *argv[])

check_lg2(git_repository_open(&repo, buf.ptr),
"Could not open repository", NULL);
git_buf_free(&buf);
git_buf_dispose(&buf);

switch (opt.cmd)
{
Expand Down
2 changes: 1 addition & 1 deletion examples/tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ static void action_delete_tag(tag_state *state)

printf("Deleted tag '%s' (was %s)\n", opts->tag_name, abbrev_oid.ptr);

git_buf_free(&abbrev_oid);
git_buf_dispose(&abbrev_oid);
git_object_free(obj);
}

Expand Down
8 changes: 4 additions & 4 deletions src/apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ static int apply_binary_delta(

if (!error && inflated.size != binary_file->inflatedlen) {
error = apply_err("inflated delta does not match expected length");
git_buf_free(out);
git_buf_dispose(out);
}

if (error < 0)
Expand All @@ -281,7 +281,7 @@ static int apply_binary_delta(
}

done:
git_buf_free(&inflated);
git_buf_dispose(&inflated);
return error;
}

Expand Down Expand Up @@ -320,9 +320,9 @@ static int apply_binary(

done:
if (error < 0)
git_buf_free(out);
git_buf_dispose(out);

git_buf_free(&reverse);
git_buf_dispose(&reverse);
return error;
}

Expand Down
8 changes: 4 additions & 4 deletions src/attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ static int system_attr_file(

/* We can safely provide a git_buf with no allocation (asize == 0) to
* a consumer. This allows them to treat this as a regular `git_buf`,
* but their call to `git_buf_free` will not attempt to free it.
* but their call to `git_buf_dispose` will not attempt to free it.
*/
git_buf_attach_notowned(
out, attr_session->sysdir.ptr, attr_session->sysdir.size);
Expand Down Expand Up @@ -359,7 +359,7 @@ static int attr_setup(git_repository *repo, git_attr_session *attr_session)
attr_session->init_setup = 1;

out:
git_buf_free(&path);
git_buf_dispose(&path);

return error;
}
Expand Down Expand Up @@ -565,8 +565,8 @@ static int collect_attr_files(
cleanup:
if (error < 0)
release_attr_files(files);
git_buf_free(&attrfile);
git_buf_free(&dir);
git_buf_dispose(&attrfile);
git_buf_dispose(&dir);

return error;
}
10 changes: 5 additions & 5 deletions src/attr_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ int git_attr_file__load(

cleanup:
git_blob_free(blob);
git_buf_free(&content);
git_buf_dispose(&content);

return error;
}
Expand Down Expand Up @@ -348,7 +348,7 @@ int git_attr_file__load_standalone(git_attr_file **out, const char *path)

if (!(error = git_futils_readbuffer(&content, path))) {
error = git_attr_file__parse_buffer(NULL, file, content.ptr);
git_buf_free(&content);
git_buf_dispose(&content);
}

if (error < 0)
Expand Down Expand Up @@ -518,7 +518,7 @@ int git_attr_path__init(

void git_attr_path__free(git_attr_path *info)
{
git_buf_free(&info->full);
git_buf_dispose(&info->full);
info->path = NULL;
info->basename = NULL;
}
Expand Down Expand Up @@ -875,8 +875,8 @@ void git_attr_session__free(git_attr_session *session)
if (!session)
return;

git_buf_free(&session->sysdir);
git_buf_free(&session->tmp);
git_buf_dispose(&session->sysdir);
git_buf_dispose(&session->tmp);

memset(session, 0, sizeof(git_attr_session));
}
4 changes: 2 additions & 2 deletions src/attrcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ static int attr_cache_lookup(
*out_file = file;
*out_entry = entry;

git_buf_free(&path);
git_buf_dispose(&path);
return error;
}

Expand Down Expand Up @@ -310,7 +310,7 @@ static int attr_cache__lookup_path(
}

git_config_entry_free(entry);
git_buf_free(&buf);
git_buf_dispose(&buf);

return error;
}
Expand Down
10 changes: 5 additions & 5 deletions src/blob.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static int write_file_filtered(
error = git_odb_write(id, odb, tgt.ptr, tgt.size, GIT_OBJ_BLOB);
}

git_buf_free(&tgt);
git_buf_dispose(&tgt);
return error;
}

Expand Down Expand Up @@ -238,7 +238,7 @@ int git_blob__create_from_paths(

done:
git_odb_free(odb);
git_buf_free(&path);
git_buf_dispose(&path);

return error;
}
Expand All @@ -257,7 +257,7 @@ int git_blob_create_fromdisk(
const char *workdir, *hintpath;

if ((error = git_path_prettify(&full_path, path, NULL)) < 0) {
git_buf_free(&full_path);
git_buf_dispose(&full_path);
return error;
}

Expand All @@ -270,7 +270,7 @@ int git_blob_create_fromdisk(
error = git_blob__create_from_paths(
id, NULL, repo, git_buf_cstr(&full_path), hintpath, 0, true);

git_buf_free(&full_path);
git_buf_dispose(&full_path);
return error;
}

Expand Down Expand Up @@ -340,7 +340,7 @@ int git_blob_create_fromstream(git_writestream **out, git_repository *repo, cons
if (error < 0)
blob_writestream_free((git_writestream *) stream);

git_buf_free(&path);
git_buf_dispose(&path);
return error;
}

Expand Down
40 changes: 20 additions & 20 deletions src/branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static int retrieve_branch_reference(

*branch_reference_out = branch; /* will be NULL on error */

git_buf_free(&ref_name);
git_buf_dispose(&ref_name);
return error;
}

Expand Down Expand Up @@ -108,8 +108,8 @@ static int create_branch(
*ref_out = branch;

cleanup:
git_buf_free(&canonical_branch_name);
git_buf_free(&log_message);
git_buf_dispose(&canonical_branch_name);
git_buf_dispose(&log_message);
return error;
}

Expand Down Expand Up @@ -199,7 +199,7 @@ int git_branch_delete(git_reference *branch)
error = git_reference_delete(branch);

on_error:
git_buf_free(&config_section);
git_buf_dispose(&config_section);
return error;
}

Expand Down Expand Up @@ -310,10 +310,10 @@ int git_branch_move(
git_buf_cstr(&new_config_section));

done:
git_buf_free(&new_reference_name);
git_buf_free(&old_config_section);
git_buf_free(&new_config_section);
git_buf_free(&log_message);
git_buf_dispose(&new_reference_name);
git_buf_dispose(&old_config_section);
git_buf_dispose(&new_config_section);
git_buf_dispose(&log_message);

return error;
}
Expand Down Expand Up @@ -366,7 +366,7 @@ static int retrieve_upstream_configuration(
return -1;

error = git_config_get_string_buf(out, config, git_buf_cstr(&buf));
git_buf_free(&buf);
git_buf_dispose(&buf);
return error;
}

Expand Down Expand Up @@ -429,9 +429,9 @@ int git_branch_upstream_name(
cleanup:
git_config_free(config);
git_remote_free(remote);
git_buf_free(&remote_name);
git_buf_free(&merge_name);
git_buf_free(&buf);
git_buf_dispose(&remote_name);
git_buf_dispose(&merge_name);
git_buf_dispose(&buf);
return error;
}

Expand Down Expand Up @@ -522,7 +522,7 @@ int git_branch_remote_name(git_buf *buf, git_repository *repo, const char *refna

cleanup:
if (error < 0)
git_buf_free(buf);
git_buf_dispose(buf);

git_strarray_free(&remote_list);
return error;
Expand All @@ -544,7 +544,7 @@ int git_branch_upstream(
git_reference_owner(branch),
git_buf_cstr(&tracking_name));

git_buf_free(&tracking_name);
git_buf_dispose(&tracking_name);
return error;
}

Expand All @@ -565,11 +565,11 @@ static int unset_upstream(git_config *config, const char *shortname)
if (git_config_delete_entry(config, git_buf_cstr(&buf)) < 0)
goto on_error;

git_buf_free(&buf);
git_buf_dispose(&buf);
return 0;

on_error:
git_buf_free(&buf);
git_buf_dispose(&buf);
return -1;
}

Expand Down Expand Up @@ -655,15 +655,15 @@ int git_branch_set_upstream(git_reference *branch, const char *upstream_name)
goto on_error;

git_reference_free(upstream);
git_buf_free(&key);
git_buf_free(&value);
git_buf_dispose(&key);
git_buf_dispose(&value);

return 0;

on_error:
git_reference_free(upstream);
git_buf_free(&key);
git_buf_free(&value);
git_buf_dispose(&key);
git_buf_dispose(&value);
git_remote_free(remote);

return -1;
Expand Down
6 changes: 3 additions & 3 deletions src/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ char *git_buf_detach(git_buf *buf)

int git_buf_attach(git_buf *buf, char *ptr, size_t asize)
{
git_buf_free(buf);
git_buf_dispose(buf);

if (ptr) {
buf->ptr = ptr;
Expand All @@ -633,7 +633,7 @@ int git_buf_attach(git_buf *buf, char *ptr, size_t asize)
void git_buf_attach_notowned(git_buf *buf, const char *ptr, size_t size)
{
if (git_buf_is_allocated(buf))
git_buf_free(buf);
git_buf_dispose(buf);

if (!size) {
git_buf_init(buf, 0);
Expand Down Expand Up @@ -954,7 +954,7 @@ int git_buf_quote(git_buf *buf)
git_buf_swap(&quoted, buf);

done:
git_buf_free(&quoted);
git_buf_dispose(&quoted);
return error;
}

Expand Down
16 changes: 8 additions & 8 deletions src/checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -1604,7 +1604,7 @@ static int blob_content_to_link(
st->st_mode = GIT_FILEMODE_LINK;
}

git_buf_free(&linktarget);
git_buf_dispose(&linktarget);

return error;
}
Expand Down Expand Up @@ -2161,13 +2161,13 @@ static int checkout_write_merge(
done:
git_filter_list_free(fl);

git_buf_free(&out_data);
git_buf_free(&our_label);
git_buf_free(&their_label);
git_buf_dispose(&out_data);
git_buf_dispose(&our_label);
git_buf_dispose(&their_label);

git_merge_file_result_free(&result);
git_buf_free(&path_workdir);
git_buf_free(&path_suffixed);
git_buf_dispose(&path_workdir);
git_buf_dispose(&path_suffixed);

return error;
}
Expand Down Expand Up @@ -2347,8 +2347,8 @@ static void checkout_data_clear(checkout_data *data)
git__free(data->pfx);
data->pfx = NULL;

git_buf_free(&data->target_path);
git_buf_free(&data->tmp);
git_buf_dispose(&data->target_path);
git_buf_dispose(&data->tmp);

git_index_free(data->index);
data->index = NULL;
Expand Down
6 changes: 3 additions & 3 deletions src/cherrypick.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static int write_cherrypick_head(
if (error < 0)
git_filebuf_cleanup(&file);

git_buf_free(&file_path);
git_buf_dispose(&file_path);

return error;
}
Expand All @@ -61,7 +61,7 @@ static int write_merge_msg(
if (error < 0)
git_filebuf_cleanup(&file);

git_buf_free(&file_path);
git_buf_dispose(&file_path);

return error;
}
Expand Down Expand Up @@ -216,7 +216,7 @@ int git_cherrypick(
git_index_free(index);
git_commit_free(our_commit);
git_reference_free(our_ref);
git_buf_free(&their_label);
git_buf_dispose(&their_label);

return error;
}
Expand Down
Loading

0 comments on commit ecf4f33

Please sign in to comment.