Skip to content

Commit

Permalink
Change 'allocVector' to 'Rf_allocVector'
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Widgren <stefan.widgren@gmail.com>
  • Loading branch information
stewid committed Jan 13, 2018
1 parent ad99b90 commit ad51ea1
Show file tree
Hide file tree
Showing 19 changed files with 104 additions and 104 deletions.
2 changes: 1 addition & 1 deletion src/git2r_blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void git2r_blame_init(git_blame *source, SEXP repo, SEXP path, SEXP dest)
SEXP s_path = Rf_install("path");

n = git_blame_get_hunk_count(source);
PROTECT(hunks = allocVector(VECSXP, n));
PROTECT(hunks = Rf_allocVector(VECSXP, n));
SET_SLOT(dest, s_hunks, hunks);
for (i = 0; i < n; i++) {
const git_blame_hunk *hunk;
Expand Down
8 changes: 4 additions & 4 deletions src/git2r_blob.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ SEXP git2r_blob_content(SEXP blob)
if (err)
goto cleanup;

PROTECT(result = allocVector(STRSXP, 1));
PROTECT(result = Rf_allocVector(STRSXP, 1));
SET_STRING_ELT(result, 0, mkChar(git_blob_rawcontent(blob_obj)));

cleanup:
Expand Down Expand Up @@ -94,7 +94,7 @@ SEXP git2r_blob_create_fromdisk(SEXP repo, SEXP path)
git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL);

len = length(path);
PROTECT(result = allocVector(VECSXP, len));
PROTECT(result = Rf_allocVector(VECSXP, len));
nprotect++;
for (i = 0; i < len; i++) {
if (NA_STRING != STRING_ELT(path, i)) {
Expand Down Expand Up @@ -159,7 +159,7 @@ SEXP git2r_blob_create_fromworkdir(SEXP repo, SEXP relative_path)
git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL);

len = length(relative_path);
PROTECT(result = allocVector(VECSXP, len));
PROTECT(result = Rf_allocVector(VECSXP, len));
nprotect++;
for (i = 0; i < len; i++) {
if (NA_STRING != STRING_ELT(relative_path, i)) {
Expand Down Expand Up @@ -247,7 +247,7 @@ SEXP git2r_blob_is_binary(SEXP blob)
if (err)
goto cleanup;

PROTECT(result = allocVector(LGLSXP, 1));
PROTECT(result = Rf_allocVector(LGLSXP, 1));
if (git_blob_is_binary(blob_obj))
LOGICAL(result)[0] = 1;
else
Expand Down
16 changes: 8 additions & 8 deletions src/git2r_branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ SEXP git2r_branch_is_head(SEXP branch)

err = git_branch_is_head(reference);
if (0 == err || 1 == err) {
PROTECT(result = allocVector(LGLSXP, 1));
PROTECT(result = Rf_allocVector(LGLSXP, 1));
LOGICAL(result)[0] = err;
err = GIT_OK;
}
Expand Down Expand Up @@ -294,8 +294,8 @@ SEXP git2r_branch_list(SEXP repo, SEXP flags)
err = git2r_branch_count(repository, INTEGER(flags)[0], &n);
if (err)
goto cleanup;
PROTECT(result = allocVector(VECSXP, n));
setAttrib(result, R_NamesSymbol, names = allocVector(STRSXP, n));
PROTECT(result = Rf_allocVector(VECSXP, n));
setAttrib(result, R_NamesSymbol, names = Rf_allocVector(STRSXP, n));

err = git_branch_iterator_new(&iter, repository, INTEGER(flags)[0]);
if (err)
Expand Down Expand Up @@ -371,7 +371,7 @@ SEXP git2r_branch_canonical_name(SEXP branch)
if (err)
goto cleanup;

PROTECT(result = allocVector(STRSXP, 1));
PROTECT(result = Rf_allocVector(STRSXP, 1));
SET_STRING_ELT(result, 0, mkChar(git_reference_name(reference)));

cleanup:
Expand Down Expand Up @@ -437,7 +437,7 @@ SEXP git2r_branch_upstream_canonical_name(SEXP branch)
if (err)
goto cleanup;

PROTECT(result = allocVector(STRSXP, 1));
PROTECT(result = Rf_allocVector(STRSXP, 1));
SET_STRING_ELT(result, 0, mkChar(name));

cleanup:
Expand Down Expand Up @@ -497,7 +497,7 @@ SEXP git2r_branch_remote_name(SEXP branch)
if (err)
goto cleanup;

PROTECT(result = allocVector(STRSXP, 1));
PROTECT(result = Rf_allocVector(STRSXP, 1));
SET_STRING_ELT(result, 0, mkChar(buf.ptr));
git_buf_free(&buf);

Expand Down Expand Up @@ -567,7 +567,7 @@ SEXP git2r_branch_remote_url(SEXP branch)
}
git_buf_free(&buf);

PROTECT(result = allocVector(STRSXP, 1));
PROTECT(result = Rf_allocVector(STRSXP, 1));
SET_STRING_ELT(result, 0, mkChar(git_remote_url(remote)));

cleanup:
Expand Down Expand Up @@ -692,7 +692,7 @@ SEXP git2r_branch_target(SEXP branch)
if (err)
goto cleanup;

PROTECT(result = allocVector(STRSXP, 1));
PROTECT(result = Rf_allocVector(STRSXP, 1));
if (GIT_REF_OID == git_reference_type(reference)) {
git_oid_fmt(sha, git_reference_target(reference));
sha[GIT_OID_HEXSZ] = '\0';
Expand Down
2 changes: 1 addition & 1 deletion src/git2r_commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ SEXP git2r_commit_parent_list(SEXP commit)
goto cleanup;

n = git_commit_parentcount(commit_obj);
PROTECT(list = allocVector(VECSXP, n));
PROTECT(list = Rf_allocVector(VECSXP, n));

for (i = 0; i < n; i++) {
git_commit *parent = NULL;
Expand Down
12 changes: 6 additions & 6 deletions src/git2r_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ static size_t git2r_config_list_init(
SET_VECTOR_ELT(
list,
i_list[level],
item = allocVector(VECSXP, n_level[level]));
setAttrib(item, R_NamesSymbol, allocVector(STRSXP, n_level[level]));
item = Rf_allocVector(VECSXP, n_level[level]));
setAttrib(item, R_NamesSymbol, Rf_allocVector(STRSXP, n_level[level]));
names = getAttrib(list, R_NamesSymbol);
SET_STRING_ELT(names, i_list[level] , mkChar(name));
}
Expand Down Expand Up @@ -304,8 +304,8 @@ SEXP git2r_config_get(SEXP repo)
n++;
}

PROTECT(result = allocVector(VECSXP, n));
setAttrib(result, R_NamesSymbol, allocVector(STRSXP, n));
PROTECT(result = Rf_allocVector(VECSXP, n));
setAttrib(result, R_NamesSymbol, Rf_allocVector(STRSXP, n));

if (git2r_config_list_variables(cfg, result, n_level))
goto cleanup;
Expand Down Expand Up @@ -414,7 +414,7 @@ SEXP git2r_config_get_string(SEXP repo, SEXP name)
goto cleanup;
}

PROTECT(result = allocVector(STRSXP, 1));
PROTECT(result = Rf_allocVector(STRSXP, 1));
SET_STRING_ELT(result, 0, mkChar(value));

cleanup:
Expand Down Expand Up @@ -459,7 +459,7 @@ SEXP git2r_config_get_logical(SEXP repo, SEXP name)
goto cleanup;
}

PROTECT(result = allocVector(LGLSXP, 1));
PROTECT(result = Rf_allocVector(LGLSXP, 1));
if (value)
LOGICAL(result)[0] = 1;
else
Expand Down
10 changes: 5 additions & 5 deletions src/git2r_diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ int git2r_diff_get_file_cb(const git_diff_delta *delta,
SET_SLOT(
VECTOR_ELT(p->result, p->file_ptr-1),
s_hunks,
hunks = allocVector(VECSXP, p->hunk_ptr));
hunks = Rf_allocVector(VECSXP, p->hunk_ptr));
for (i = 0; i < len ; i++)
SET_VECTOR_ELT(hunks, i, VECTOR_ELT(p->hunk_tmp, i));
}
Expand Down Expand Up @@ -852,7 +852,7 @@ int git2r_diff_get_hunk_cb(const git_diff_delta *delta,
size_t len=p->line_ptr, i;
SEXP s_lines = Rf_install("lines");

PROTECT(lines = allocVector(VECSXP, p->line_ptr));
PROTECT(lines = Rf_allocVector(VECSXP, p->line_ptr));
SET_SLOT(VECTOR_ELT(p->hunk_tmp, p->hunk_ptr-1), s_lines, lines);
for (i = 0; i < len; i++)
SET_VECTOR_ELT(lines, i, VECTOR_ELT(p->line_tmp, i));
Expand Down Expand Up @@ -973,10 +973,10 @@ int git2r_diff_format_to_r(git_diff *diff, SEXP dest)
if (err)
return err;

PROTECT(payload.result = allocVector(VECSXP, num_files));
PROTECT(payload.result = Rf_allocVector(VECSXP, num_files));
SET_SLOT(dest, Rf_install("files"), payload.result);
PROTECT(payload.hunk_tmp = allocVector(VECSXP, max_hunks));
PROTECT(payload.line_tmp = allocVector(VECSXP, max_lines));
PROTECT(payload.hunk_tmp = Rf_allocVector(VECSXP, max_hunks));
PROTECT(payload.line_tmp = Rf_allocVector(VECSXP, max_lines));

err = git_diff_foreach(
diff,
Expand Down
2 changes: 1 addition & 1 deletion src/git2r_graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ SEXP git2r_graph_ahead_behind(SEXP local, SEXP upstream)
if (err)
goto cleanup;

PROTECT(result = allocVector(INTSXP, 2));
PROTECT(result = Rf_allocVector(INTSXP, 2));
nprotect++;
INTEGER(result)[0] = ahead;
INTEGER(result)[1] = behind;
Expand Down
8 changes: 4 additions & 4 deletions src/git2r_libgit2.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ SEXP git2r_libgit2_features(void)
int value;

value = git_libgit2_features();
PROTECT(features = allocVector(VECSXP, 3));
setAttrib(features, R_NamesSymbol, names = allocVector(STRSXP, 3));
PROTECT(features = Rf_allocVector(VECSXP, 3));
setAttrib(features, R_NamesSymbol, names = Rf_allocVector(STRSXP, 3));

SET_STRING_ELT(names, 0, mkChar("threads"));
if (value & GIT_FEATURE_THREADS)
Expand Down Expand Up @@ -69,8 +69,8 @@ SEXP git2r_libgit2_version(void)
int major, minor, rev;

git_libgit2_version(&major, &minor, &rev);
PROTECT(version = allocVector(VECSXP, 3));
setAttrib(version, R_NamesSymbol, names = allocVector(STRSXP, 3));
PROTECT(version = Rf_allocVector(VECSXP, 3));
setAttrib(version, R_NamesSymbol, names = Rf_allocVector(STRSXP, 3));
SET_VECTOR_ELT(version, 0, ScalarInteger(major));
SET_VECTOR_ELT(version, 1, ScalarInteger(minor));
SET_VECTOR_ELT(version, 2, ScalarInteger(rev));
Expand Down
6 changes: 3 additions & 3 deletions src/git2r_note.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ SEXP git2r_note_default_ref(SEXP repo)
if (err)
goto cleanup;

PROTECT(result = allocVector(STRSXP, 1));
PROTECT(result = Rf_allocVector(STRSXP, 1));
SET_STRING_ELT(result, 0, mkChar(buf.ptr));

cleanup:
Expand Down Expand Up @@ -310,13 +310,13 @@ SEXP git2r_notes(SEXP repo, SEXP ref)
if (err) {
if (GIT_ENOTFOUND == err) {
err = GIT_OK;
PROTECT(result = allocVector(VECSXP, 0));
PROTECT(result = Rf_allocVector(VECSXP, 0));
}

goto cleanup;
}

PROTECT(result = allocVector(VECSXP, cb_data.n));
PROTECT(result = Rf_allocVector(VECSXP, cb_data.n));
cb_data.n = 0;
cb_data.list = result;
cb_data.repo = repo;
Expand Down
32 changes: 16 additions & 16 deletions src/git2r_odb.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ SEXP git2r_odb_hash(SEXP data)
git2r_error(__func__, NULL, "'data'", git2r_err_string_vec_arg);

len = length(data);
PROTECT(result = allocVector(STRSXP, len));
PROTECT(result = Rf_allocVector(STRSXP, len));
for (i = 0; i < len; i++) {
if (NA_STRING == STRING_ELT(data, i)) {
SET_STRING_ELT(result, i, NA_STRING);
Expand Down Expand Up @@ -89,7 +89,7 @@ SEXP git2r_odb_hashfile(SEXP path)
git2r_error(__func__, NULL, "'path'", git2r_err_string_vec_arg);

len = length(path);
PROTECT(result = allocVector(STRSXP, len));
PROTECT(result = Rf_allocVector(STRSXP, len));
for (i = 0; i < len; i++) {
if (NA_STRING == STRING_ELT(path, i)) {
SET_STRING_ELT(result, i, NA_STRING);
Expand Down Expand Up @@ -229,15 +229,15 @@ SEXP git2r_odb_objects(SEXP repo)
if (err)
goto cleanup;

PROTECT(result = allocVector(VECSXP, 3));
setAttrib(result, R_NamesSymbol, names = allocVector(STRSXP, 3));
PROTECT(result = Rf_allocVector(VECSXP, 3));
setAttrib(result, R_NamesSymbol, names = Rf_allocVector(STRSXP, 3));

i = 0;
SET_VECTOR_ELT(result, i, allocVector(STRSXP, cb_data.n));
SET_VECTOR_ELT(result, i, Rf_allocVector(STRSXP, cb_data.n));
SET_STRING_ELT(names, i++, mkChar("sha"));
SET_VECTOR_ELT(result, i, allocVector(STRSXP, cb_data.n));
SET_VECTOR_ELT(result, i, Rf_allocVector(STRSXP, cb_data.n));
SET_STRING_ELT(names, i++, mkChar("type"));
SET_VECTOR_ELT(result, i, allocVector(INTSXP, cb_data.n));
SET_VECTOR_ELT(result, i, Rf_allocVector(INTSXP, cb_data.n));
SET_STRING_ELT(names, i++, mkChar("len"));

cb_data.list = result;
Expand Down Expand Up @@ -504,23 +504,23 @@ SEXP git2r_odb_blobs(SEXP repo)
if (err)
goto cleanup;

PROTECT(result = allocVector(VECSXP, 7));
setAttrib(result, R_NamesSymbol, names = allocVector(STRSXP, 7));
PROTECT(result = Rf_allocVector(VECSXP, 7));
setAttrib(result, R_NamesSymbol, names = Rf_allocVector(STRSXP, 7));

i = 0;
SET_VECTOR_ELT(result, i, allocVector(STRSXP, cb_data.n));
SET_VECTOR_ELT(result, i, Rf_allocVector(STRSXP, cb_data.n));
SET_STRING_ELT(names, i++, mkChar("sha"));
SET_VECTOR_ELT(result, i, allocVector(STRSXP, cb_data.n));
SET_VECTOR_ELT(result, i, Rf_allocVector(STRSXP, cb_data.n));
SET_STRING_ELT(names, i++, mkChar("path"));
SET_VECTOR_ELT(result, i, allocVector(STRSXP, cb_data.n));
SET_VECTOR_ELT(result, i, Rf_allocVector(STRSXP, cb_data.n));
SET_STRING_ELT(names, i++, mkChar("name"));
SET_VECTOR_ELT(result, i, allocVector(INTSXP, cb_data.n));
SET_VECTOR_ELT(result, i, Rf_allocVector(INTSXP, cb_data.n));
SET_STRING_ELT(names, i++, mkChar("len"));
SET_VECTOR_ELT(result, i, allocVector(STRSXP, cb_data.n));
SET_VECTOR_ELT(result, i, Rf_allocVector(STRSXP, cb_data.n));
SET_STRING_ELT(names, i++, mkChar("commit"));
SET_VECTOR_ELT(result, i, allocVector(STRSXP, cb_data.n));
SET_VECTOR_ELT(result, i, Rf_allocVector(STRSXP, cb_data.n));
SET_STRING_ELT(names, i++, mkChar("author"));
SET_VECTOR_ELT(result, i, allocVector(REALSXP, cb_data.n));
SET_VECTOR_ELT(result, i, Rf_allocVector(REALSXP, cb_data.n));
SET_STRING_ELT(names, i++, mkChar("when"));

cb_data.list = result;
Expand Down
6 changes: 3 additions & 3 deletions src/git2r_reference.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ SEXP git2r_reference_dwim(SEXP repo, SEXP shorthand)
if (err)
goto cleanup;

PROTECT(result = allocVector(STRSXP, 1));
PROTECT(result = Rf_allocVector(STRSXP, 1));
SET_STRING_ELT(result, 0, mkChar(git_reference_name(reference)));

cleanup:
Expand Down Expand Up @@ -130,11 +130,11 @@ SEXP git2r_reference_list(SEXP repo)
if (err)
goto cleanup;

PROTECT(result = allocVector(VECSXP, ref_list.count));
PROTECT(result = Rf_allocVector(VECSXP, ref_list.count));
setAttrib(
result,
R_NamesSymbol,
names = allocVector(STRSXP, ref_list.count));
names = Rf_allocVector(STRSXP, ref_list.count));

for (i = 0; i < ref_list.count; i++) {
SEXP reference;
Expand Down
4 changes: 2 additions & 2 deletions src/git2r_reflog.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void git2r_reflog_entry_init(
sha[GIT_OID_HEXSZ] = '\0';
SET_SLOT(dest, s_sha, mkString(sha));

SET_SLOT(dest, s_index, i = allocVector(INTSXP, 1));
SET_SLOT(dest, s_index, i = Rf_allocVector(INTSXP, 1));
INTEGER(i)[0] = index;

committer = git_reflog_entry_committer(source);
Expand Down Expand Up @@ -101,7 +101,7 @@ SEXP git2r_reflog_list(SEXP repo, SEXP ref)
goto cleanup;

n = git_reflog_entrycount(reflog);
PROTECT(result = allocVector(VECSXP, n));
PROTECT(result = Rf_allocVector(VECSXP, n));
for (i = 0; i < n; i++) {
const git_reflog_entry *entry = git_reflog_entry_byindex(reflog, i);

Expand Down
8 changes: 4 additions & 4 deletions src/git2r_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ SEXP git2r_remote_list(SEXP repo)
if (err)
goto cleanup;

PROTECT(list = allocVector(STRSXP, rem_list.count));
PROTECT(list = Rf_allocVector(STRSXP, rem_list.count));
for (i = 0; i < rem_list.count; i++)
SET_STRING_ELT(list, i, mkChar(rem_list.strings[i]));

Expand Down Expand Up @@ -404,7 +404,7 @@ SEXP git2r_remote_url(SEXP repo, SEXP remote)
git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL);

len = LENGTH(remote);
PROTECT(url = allocVector(STRSXP, len));
PROTECT(url = Rf_allocVector(STRSXP, len));

for (; i < len; i++) {
if (NA_STRING == STRING_ELT(remote, i)) {
Expand Down Expand Up @@ -488,8 +488,8 @@ SEXP git2r_remote_ls(SEXP name, SEXP repo, SEXP credentials)
if (err)
goto cleanup;

PROTECT(result = allocVector(STRSXP, refs_len));
setAttrib(result, R_NamesSymbol, names = allocVector(STRSXP, refs_len));
PROTECT(result = Rf_allocVector(STRSXP, refs_len));
setAttrib(result, R_NamesSymbol, names = Rf_allocVector(STRSXP, refs_len));

for (i = 0; i < refs_len; i++) {
char oid[GIT_OID_HEXSZ + 1] = {0};
Expand Down
Loading

0 comments on commit ad51ea1

Please sign in to comment.