From bf212b90b0287e0ba7b020eacd33f43eac6dac47 Mon Sep 17 00:00:00 2001 From: Antonov548 Date: Sun, 2 Jul 2023 16:23:00 +0200 Subject: [PATCH 1/2] use external pointer --- src/rinterface_extra.c | 53 ++---------------------------------------- 1 file changed, 2 insertions(+), 51 deletions(-) diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 9535ae2a9c2..056f8590310 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -2884,26 +2884,6 @@ void R_igraph_get_to(SEXP graph, igraph_vector_t* to) { *to = pgraph->to; } -void R_igraph_get_oi(SEXP graph, igraph_vector_t* oi) { - igraph_t *pgraph=R_igraph_get_pointer(graph); - *oi = pgraph->oi; -} - -void R_igraph_get_ii(SEXP graph, igraph_vector_t* ii) { - igraph_t *pgraph=R_igraph_get_pointer(graph); - *ii = pgraph->ii; -} - -void R_igraph_get_os(SEXP graph, igraph_vector_t* os) { - igraph_t *pgraph=R_igraph_get_pointer(graph); - *os = pgraph->os; -} - -void R_igraph_get_is(SEXP graph, igraph_vector_t* is) { - igraph_t *pgraph=R_igraph_get_pointer(graph); - *is = pgraph->is; -} - SEXP R_igraph_to_SEXP(const igraph_t *graph) { SEXP result; @@ -3529,15 +3509,7 @@ int R_igraph_SEXP_to_array3_copy(SEXP rval, igraph_array3_t *a) { } int R_SEXP_to_igraph(SEXP graph, igraph_t *res) { - - res->n=R_igraph_get_n(graph); - res->directed=R_igraph_get_directed(graph); - R_igraph_get_from(graph, &res->from); - R_igraph_get_to(graph, &res->to); - R_igraph_get_oi(graph, &res->oi); - R_igraph_get_ii(graph, &res->ii); - R_igraph_get_os(graph, &res->os); - R_igraph_get_is(graph, &res->is); + *res = *R_igraph_get_pointer(graph); /* attributes */ res->attr=VECTOR_ELT(graph, igraph_t_idx_attr); @@ -3546,28 +3518,7 @@ int R_SEXP_to_igraph(SEXP graph, igraph_t *res) { } int R_SEXP_to_igraph_copy(SEXP graph, igraph_t *res) { - - res->n=R_igraph_get_n(graph); - res->directed=R_igraph_get_directed(graph); - - igraph_vector_t from; - R_igraph_get_from(graph, &from); - igraph_vector_copy(&res->from, &from); - igraph_vector_t to; - R_igraph_get_to(graph, &to); - igraph_vector_copy(&res->to, &to); - igraph_vector_t oi; - R_igraph_get_oi(graph, &oi); - igraph_vector_copy(&res->oi, &oi); - igraph_vector_t ii; - R_igraph_get_ii(graph, &ii); - igraph_vector_copy(&res->ii, &ii); - igraph_vector_t os; - R_igraph_get_os(graph, &os); - igraph_vector_copy(&res->os, &os); - igraph_vector_t is; - R_igraph_get_is(graph, &is); - igraph_vector_copy(&res->is, &is); + igraph_copy(res, R_igraph_get_pointer(graph)); /* attributes */ res->attr=VECTOR_ELT(graph, igraph_t_idx_attr); From 6501314b8a82ae53d06baf6ea9e5baf69f428367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 4 Jul 2023 08:48:22 +0200 Subject: [PATCH 2/2] Unclear --- src/rinterface_extra.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 056f8590310..552b1e16bfa 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -3521,6 +3521,7 @@ int R_SEXP_to_igraph_copy(SEXP graph, igraph_t *res) { igraph_copy(res, R_igraph_get_pointer(graph)); /* attributes */ + /* FIXME: Why is this necessary? */ res->attr=VECTOR_ELT(graph, igraph_t_idx_attr); return 0;