Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 4 additions & 34 deletions src/rinterface_extra.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,6 @@ int R_igraph_attribute_init(igraph_t *graph, igraph_vector_ptr_t *attr) {
void R_igraph_attribute_destroy(igraph_t *graph) {
SEXP attr=graph->attr;
REAL(VECTOR_ELT(attr, 0))[1] -= 1; /* refcount for igraph_t */
if (!R_igraph_attribute_protected &&
REAL(VECTOR_ELT(attr, 0))[1]==0 &&
REAL(VECTOR_ELT(attr, 0))[2]==1) {
R_ReleaseObject(attr);
}
graph->attr=0;
}

Expand All @@ -465,10 +460,6 @@ int R_igraph_attribute_copy(igraph_t *to, const igraph_t *from,
if (ga && va && ea) {
to->attr=from->attr;
REAL(VECTOR_ELT(fromattr, 0))[1] += 1; /* refcount only */
if (!R_igraph_attribute_protected &&
REAL(VECTOR_ELT(fromattr, 0))[1] == 1) {
R_PreserveObject(to->attr);
}
} else {
R_igraph_attribute_init(to,0); /* Sets up many things */
SEXP toattr=to->attr;
Expand Down Expand Up @@ -591,15 +582,9 @@ SEXP R_igraph_attribute_add_vertices_dup(SEXP attr) {

if (R_igraph_attribute_protected) {
PROTECT(newattr); px++;
} else {
R_PreserveObject(newattr);
}

REAL(VECTOR_ELT(attr, 0))[1] -= 1;
if (!R_igraph_attribute_protected &&
REAL(VECTOR_ELT(attr, 0))[1] == 0) {
R_ReleaseObject(attr);
}
REAL(VECTOR_ELT(newattr, 0))[0] = 0;
REAL(VECTOR_ELT(newattr, 0))[1] = 1;
if (R_igraph_attribute_protected) {
Expand Down Expand Up @@ -777,14 +762,8 @@ int R_igraph_attribute_permute_vertices_same(const igraph_t *graph,
SEXP newattr = Rf_duplicate(attr);
if (R_igraph_attribute_protected) {
PROTECT(newattr); px++;
} else {
R_PreserveObject(newattr);
}
REAL(VECTOR_ELT(attr, 0))[1] -= 1;
if (!R_igraph_attribute_protected &&
REAL(VECTOR_ELT(attr, 0))[1] == 0) {
R_ReleaseObject(attr);
}
REAL(VECTOR_ELT(newattr, 0))[0] = 0;
REAL(VECTOR_ELT(newattr, 0))[1] = 1;
if (R_igraph_attribute_protected) {
Expand Down Expand Up @@ -894,15 +873,9 @@ SEXP R_igraph_attribute_add_edges_dup(SEXP attr) {

if (R_igraph_attribute_protected) {
PROTECT(newattr); px++;
} else {
R_PreserveObject(newattr);
}

REAL(VECTOR_ELT(attr, 0))[1] -= 1;
if (!R_igraph_attribute_protected &&
REAL(VECTOR_ELT(attr, 0))[1] == 0) {
R_ReleaseObject(attr);
}
REAL(VECTOR_ELT(newattr, 0))[0] = 0;
REAL(VECTOR_ELT(newattr, 0))[1] = 1;
if (R_igraph_attribute_protected) {
Expand Down Expand Up @@ -1161,14 +1134,8 @@ int R_igraph_attribute_permute_edges_same(const igraph_t *graph,
SEXP newattr=Rf_duplicate(attr);
if (R_igraph_attribute_protected) {
PROTECT(newattr); px++;
} else {
R_PreserveObject(newattr);
}
REAL(VECTOR_ELT(attr, 0))[1] -= 1;
if (!R_igraph_attribute_protected &&
REAL(VECTOR_ELT(attr, 0))[1] == 0) {
R_ReleaseObject(attr);
}
REAL(VECTOR_ELT(newattr, 0))[0] = 0;
REAL(VECTOR_ELT(newattr, 0))[1] = 1;
if (R_igraph_attribute_protected) {
Expand Down Expand Up @@ -3095,6 +3062,9 @@ SEXP R_igraph_to_SEXP(const igraph_t *graph) {

/* Attributes */
SET_VECTOR_ELT(result, igraph_t_idx_attr, graph->attr);
if (!R_igraph_attribute_protected) {
R_ReleaseObject(graph->attr);
}
REAL(VECTOR_ELT(graph->attr, 0))[0] += 1;

/* Environment for vertex/edge seqs */
Expand Down Expand Up @@ -3752,7 +3722,7 @@ int R_SEXP_to_igraph_copy(SEXP graph, igraph_t *res) {
/* attributes */
REAL(VECTOR_ELT(VECTOR_ELT(graph, igraph_t_idx_attr), 0))[0] = 1; /* R objects */
REAL(VECTOR_ELT(VECTOR_ELT(graph, igraph_t_idx_attr), 0))[1] = 1; /* igraph_t objects */
R_PreserveObject(res->attr=VECTOR_ELT(graph, igraph_t_idx_attr));
res->attr=VECTOR_ELT(graph, igraph_t_idx_attr);

return 0;
}
Expand Down