From 239e03bc75f3276e4e4e3881489b34eb9660afb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Wed, 11 Dec 2024 10:50:53 +0100 Subject: [PATCH 1/5] feat: Use `_pv` destroy functions to satisfy UBSAN checks --- src/rinterface.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/rinterface.c b/src/rinterface.c index dc9615cf15..0b66ede1f9 100644 --- a/src/rinterface.c +++ b/src/rinterface.c @@ -24,6 +24,20 @@ #include "rinterface.h" +// This is a variant of IGRAPH_FINALLY that satisfies UBSAN checks. +#define IGRAPH_FINALLY_PV(func, ptr) \ + do { \ + /* the following branch makes the compiler check the compatibility of \ + * func and ptr to detect cases when we are accidentally invoking an \ + * incorrect destructor function with the pointer */ \ + if (0) { func(ptr); } \ + IGRAPH_FINALLY_REAL((func##_pv), (ptr)); \ + } while (0) + +void igraph_vector_int_destroy_pv(void* pv_ptr) { + igraph_vector_int_destroy((igraph_vector_int_t*) pv_ptr); +} + /***********************************************/ /* THE REST IS GENERATED BY stimulus */ /***********************************************/ @@ -11272,7 +11286,7 @@ SEXP R_igraph_eulerian_cycle(SEXP graph) { if (0 != igraph_vector_int_init(&c_vertex_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_res); + IGRAPH_FINALLY_PV(igraph_vector_int_destroy, &c_vertex_res); /* Call igraph */ IGRAPH_R_CHECK(igraph_eulerian_cycle(&c_graph, &c_edge_res, &c_vertex_res)); From 27ca6ab380715802870e1316815cc3a8c02af81e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Wed, 11 Dec 2024 11:00:38 +0100 Subject: [PATCH 2/5] Satisfy Stimulus --- src/vendor/cigraph/interfaces/functions.yaml | 2 +- src/vendor/cigraph/interfaces/types.yaml | 7 +++++++ tools/stimulus/types-RC.yaml | 21 ++++++++++++++++++++ tools/stimulus/types-RR.yaml | 13 ++++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/vendor/cigraph/interfaces/functions.yaml b/src/vendor/cigraph/interfaces/functions.yaml index 7f7f02ee21..34f3b99384 100644 --- a/src/vendor/cigraph/interfaces/functions.yaml +++ b/src/vendor/cigraph/interfaces/functions.yaml @@ -2524,7 +2524,7 @@ igraph_eulerian_path: DEPS: edge_res ON graph, vertex_res ON graph igraph_eulerian_cycle: - PARAMS: GRAPH graph, OPTIONAL OUT EDGE_INDICES edge_res, OPTIONAL OUT VERTEX_INDICES vertex_res + PARAMS: GRAPH graph, OPTIONAL OUT EDGE_INDICES edge_res, OPTIONAL OUT VERTEX_INDICES_PV vertex_res DEPS: edge_res ON graph, vertex_res ON graph ####################################### diff --git a/src/vendor/cigraph/interfaces/types.yaml b/src/vendor/cigraph/interfaces/types.yaml index 06d66dd4ee..27fd70c03b 100644 --- a/src/vendor/cigraph/interfaces/types.yaml +++ b/src/vendor/cigraph/interfaces/types.yaml @@ -157,6 +157,13 @@ VERTEX_INDICES: CTYPE: igraph_vector_int_t FLAGS: BY_REF +# Temporary, for https://github.com/igraph/rigraph/pull/1630 +# We should call the `_PV` versions for all types in the future. +VERTEX_INDICES_PV: + # An integer vector containing vertex indices. + CTYPE: igraph_vector_int_t + FLAGS: BY_REF + VERTEX_INDEX_PAIRS: # An integer vector containing pairs of vertex indices, in a flattened # representation diff --git a/tools/stimulus/types-RC.yaml b/tools/stimulus/types-RC.yaml index 0b563a9648..8530ccbd4e 100644 --- a/tools/stimulus/types-RC.yaml +++ b/tools/stimulus/types-RC.yaml @@ -536,6 +536,27 @@ VERTEX_INDICES: igraph_vector_int_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); +VERTEX_INDICES_PV: + CALL: '&%C%' + CTYPE: igraph_vector_int_t + INCONV: + IN: |- + R_SEXP_to_vector_int_copy(%I%, &%C%); + IGRAPH_FINALLY_PV(igraph_vector_int_destroy, &%C%); + OUT: |- + if (0 != igraph_vector_int_init(&%C%, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY_PV(igraph_vector_int_destroy, &%C%); + OUTCONV: + IN: |- + igraph_vector_int_destroy(&%C%); + IGRAPH_FINALLY_CLEAN(1); + OUT: |- + PROTECT(%I%=R_igraph_vector_int_to_SEXPp1(&%C%)); + igraph_vector_int_destroy(&%C%); + IGRAPH_FINALLY_CLEAN(1); + VERTEX_INDEX_PAIRS: CALL: '&%C%' CTYPE: igraph_vector_int_t diff --git a/tools/stimulus/types-RR.yaml b/tools/stimulus/types-RR.yaml index c72ed787de..c1becd741b 100644 --- a/tools/stimulus/types-RR.yaml +++ b/tools/stimulus/types-RR.yaml @@ -141,6 +141,19 @@ VERTEX_INDICES: %I% <- create_vs(%I1%, %I%) } +# Temporary, for https://github.com/igraph/rigraph/pull/1630 +# We should call the `_PV` versions for all types in the future. +VERTEX_INDICES_PV: + CALL: '%I%-1' + DEFAULT: + ALL: V(%I1%) + INCONV: '%I% <- as_igraph_vs(%I1%, %I%)' + OUTCONV: + OUT: |- + if (igraph_opt("return.vs.es")) { + %I% <- create_vs(%I1%, %I%) + } + EDGE_INDICES: CALL: '%I%-1' DEFAULT: From 367f89e1ecf08d7006a07782066a5229dedffc1b Mon Sep 17 00:00:00 2001 From: Antonov548 Date: Wed, 11 Dec 2024 13:27:13 +0100 Subject: [PATCH 3/5] move to proper place --- src/rinterface.c | 14 -------------- src/rinterface.h | 12 ++++++++++++ src/rinterface_extra.c | 5 +++++ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/rinterface.c b/src/rinterface.c index 0b66ede1f9..4d1365f4a4 100644 --- a/src/rinterface.c +++ b/src/rinterface.c @@ -24,20 +24,6 @@ #include "rinterface.h" -// This is a variant of IGRAPH_FINALLY that satisfies UBSAN checks. -#define IGRAPH_FINALLY_PV(func, ptr) \ - do { \ - /* the following branch makes the compiler check the compatibility of \ - * func and ptr to detect cases when we are accidentally invoking an \ - * incorrect destructor function with the pointer */ \ - if (0) { func(ptr); } \ - IGRAPH_FINALLY_REAL((func##_pv), (ptr)); \ - } while (0) - -void igraph_vector_int_destroy_pv(void* pv_ptr) { - igraph_vector_int_destroy((igraph_vector_int_t*) pv_ptr); -} - /***********************************************/ /* THE REST IS GENERATED BY stimulus */ /***********************************************/ diff --git a/src/rinterface.h b/src/rinterface.h index 2ef7b02705..5df48f96f5 100644 --- a/src/rinterface.h +++ b/src/rinterface.h @@ -120,6 +120,18 @@ igraph_error_t R_SEXP_to_attr_comb(SEXP input, igraph_attribute_combination_t *c else if (__c != IGRAPH_SUCCESS) { R_igraph_error(); } \ } while (0) +// This is a variant of IGRAPH_FINALLY that satisfies UBSAN checks. +#define IGRAPH_FINALLY_PV(func, ptr) \ + do { \ + /* the following branch makes the compiler check the compatibility of \ + * func and ptr to detect cases when we are accidentally invoking an \ + * incorrect destructor function with the pointer */ \ + if (0) { func(ptr); } \ + IGRAPH_FINALLY_REAL((func##_pv), (ptr)); \ + } while (0) + +void igraph_vector_int_destroy_pv(void* pv_ptr); + #define IGRAPH_R_CHECK_INT(v) R_check_int_scalar(v) #define IGRAPH_R_CHECK_REAL(v) R_check_real_scalar(v) #define IGRAPH_R_CHECK_BOOL(v) R_check_bool_scalar(v) diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 08ddbda3c4..250edd44c2 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -99,6 +99,11 @@ void R_check_bool_scalar(SEXP value) } } +void igraph_vector_int_destroy_pv(void* pv_ptr) +{ + igraph_vector_int_destroy((igraph_vector_int_t*) pv_ptr); +} + SEXP R_igraph_i_lang7(SEXP s, SEXP t, SEXP u, SEXP v, SEXP w, SEXP x, SEXP y) { PROTECT(s); From f5b816a346fa66f6cf89e1027e316ba3b68c3fe4 Mon Sep 17 00:00:00 2001 From: Antonov548 Date: Thu, 2 Jan 2025 21:32:21 +0100 Subject: [PATCH 4/5] use _pv function for vector_int/igraph/vector/matrix/bool --- src/rinterface.h | 7 +- src/rinterface_extra.c | 481 ++++++++++++++++++++++------------------- 2 files changed, 259 insertions(+), 229 deletions(-) diff --git a/src/rinterface.h b/src/rinterface.h index b01fa51b0a..04e0192e37 100644 --- a/src/rinterface.h +++ b/src/rinterface.h @@ -130,7 +130,12 @@ igraph_error_t R_SEXP_to_attr_comb(SEXP input, igraph_attribute_combination_t *c IGRAPH_FINALLY_REAL((func##_pv), (ptr)); \ } while (0) -void igraph_vector_int_destroy_pv(void* pv_ptr); +void igraph_destroy_pv(void *pv_ptr); +void igraph_matrix_destroy_pv(void *pv_ptr); +void igraph_vector_destroy_pv(void *pv_ptr); +void igraph_vector_int_destroy_pv(void *pv_ptr); +void igraph_vector_bool_destroy_pv(void *pv_ptr); +void igraph_vector_int_list_destroy_pv(void *pv_ptr); #define IGRAPH_R_CHECK_INT(v) R_check_int_scalar(v) #define IGRAPH_R_CHECK_REAL(v) R_check_real_scalar(v) diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 12cdd93e39..2014abe438 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -99,11 +99,36 @@ void R_check_bool_scalar(SEXP value) } } +void igraph_destroy_pv(void* pv_ptr) +{ + igraph_destroy((igraph_t*) pv_ptr); +} + +void igraph_matrix_destroy_pv(void *pv_ptr) +{ + igraph_matrix_destroy((igraph_matrix_t*) pv_ptr); +} + +void igraph_vector_destroy_pv(void *pv_ptr) +{ + igraph_vector_destroy((igraph_vector_t*) pv_ptr); +} + void igraph_vector_int_destroy_pv(void* pv_ptr) { igraph_vector_int_destroy((igraph_vector_int_t*) pv_ptr); } +void igraph_vector_bool_destroy_pv(void *pv_ptr) +{ + igraph_vector_bool_destroy((igraph_vector_bool_t*) pv_ptr); +} + +void igraph_vector_int_list_destroy_pv(void *pv_ptr) +{ + igraph_vector_int_list_destroy((igraph_vector_int_list_t*) pv_ptr); +} + igraph_error_t R_get_int_scalar(SEXP sexp, R_xlen_t index, igraph_integer_t *res) { if (Rf_xlength(sexp) <= index) @@ -591,7 +616,7 @@ igraph_error_t R_igraph_attribute_add_vertices(igraph_t *graph, igraph_integer_t /* First add the new attributes, if any */ newattrs=0; if (igraph_vector_int_init(&news, 0)) Rf_error("Out of memory"); - IGRAPH_FINALLY(igraph_vector_int_destroy, &news); + IGRAPH_FINALLY_PV(igraph_vector_int_destroy, &news); for (igraph_integer_t i=0; iname; @@ -625,7 +650,7 @@ igraph_error_t R_igraph_attribute_add_vertices(igraph_t *graph, igraph_integer_t val=VECTOR_ELT(attr, 2); UNPROTECT(9); } - igraph_vector_int_destroy(&news); + igraph_vector_int_destroy_pv(&news); IGRAPH_FINALLY_CLEAN(1); /* news */ /* Now append the new values */ @@ -911,7 +936,7 @@ igraph_error_t R_igraph_attribute_add_edges(igraph_t *graph, const igraph_vector int px = 0; if (igraph_vector_int_init(&news, 0)) Rf_error("Out of memory"); - IGRAPH_FINALLY(igraph_vector_int_destroy, &news); + IGRAPH_FINALLY_PV(igraph_vector_int_destroy, &news); SEXP newattr = PROTECT(R_igraph_attribute_add_edges_dup(attr)); px++; attr=graph->attr=newattr; @@ -962,7 +987,7 @@ igraph_error_t R_igraph_attribute_add_edges(igraph_t *graph, const igraph_vector eal=VECTOR_ELT(attr, 3); UNPROTECT(9); } - igraph_vector_int_destroy(&news); + igraph_vector_int_destroy_pv(&news); IGRAPH_FINALLY_CLEAN(1); /* Now append the new values */ @@ -1287,7 +1312,7 @@ igraph_error_t R_igraph_attribute_get_numeric_vertex_attr(const igraph_t *graph, if (igraph_vs_is_all(&vs)) { R_SEXP_to_vector_copy(AS_NUMERIC(va), &newvalue); - igraph_vector_destroy(value); + igraph_vector_destroy_pv(value); *value=newvalue; } else { igraph_vit_t it; @@ -1335,7 +1360,7 @@ igraph_error_t R_igraph_attribute_get_bool_vertex_attr(const igraph_t *graph, if (igraph_vs_is_all(&vs)) { R_SEXP_to_vector_bool_copy(va, &newvalue); - igraph_vector_bool_destroy(value); + igraph_vector_bool_destroy_pv(value); *value=newvalue; } else { igraph_vit_t it; @@ -1412,7 +1437,7 @@ igraph_error_t R_igraph_attribute_get_numeric_edge_attr(const igraph_t *graph, if (igraph_es_is_all(&es)) { R_SEXP_to_vector_copy(AS_NUMERIC(ea), &newvalue); - igraph_vector_destroy(value); + igraph_vector_destroy_pv(value); *value=newvalue; } else { igraph_eit_t it; @@ -1460,7 +1485,7 @@ igraph_error_t R_igraph_attribute_get_bool_edge_attr(const igraph_t *graph, if (igraph_es_is_all(&es)) { R_SEXP_to_vector_bool_copy(ea, &newvalue); - igraph_vector_bool_destroy(value); + igraph_vector_bool_destroy_pv(value); *value=newvalue; } else { igraph_eit_t it; @@ -2550,7 +2575,7 @@ SEXP R_igraph_0orvector_int_to_SEXP_d(igraph_vector_int_t *v) { SEXP result; if (v) { PROTECT(result=R_igraph_vector_int_to_SEXP(v)); - igraph_vector_int_destroy(v); + igraph_vector_int_destroy_pv(v); } else { PROTECT(result=R_NilValue); } @@ -2797,11 +2822,11 @@ static igraph_error_t restore_pointer(SEXP graph, igraph_t *g) { igraph_vector_int_t from; R_SEXP_to_vector_int_copy(VECTOR_ELT(graph, igraph_t_idx_from), &from); - IGRAPH_FINALLY(igraph_vector_int_destroy, &from); + IGRAPH_FINALLY_PV(igraph_vector_int_destroy, &from); igraph_vector_int_t to; R_SEXP_to_vector_int_copy(VECTOR_ELT(graph, igraph_t_idx_to), &to); - IGRAPH_FINALLY(igraph_vector_int_destroy, &to); + IGRAPH_FINALLY_PV(igraph_vector_int_destroy, &to); igraph_vector_int_t edges; igraph_integer_t no_of_edges=igraph_vector_int_size(&from); @@ -2813,12 +2838,12 @@ static igraph_error_t restore_pointer(SEXP graph, igraph_t *g) { } IGRAPH_CHECK(igraph_empty(g, no_of_nodes, directed)); - IGRAPH_FINALLY(igraph_destroy, g); + IGRAPH_FINALLY_PV(igraph_destroy, g); IGRAPH_CHECK(igraph_add_edges(g, &edges, NULL)); - igraph_vector_int_destroy(&from); - igraph_vector_int_destroy(&to); - igraph_vector_int_destroy(&edges); + igraph_vector_int_destroy_pv(&from); + igraph_vector_int_destroy_pv(&to); + igraph_vector_int_destroy_pv(&edges); IGRAPH_FINALLY_CLEAN(4); /* +1 for g */ return IGRAPH_SUCCESS; @@ -3044,19 +3069,19 @@ SEXP R_igraph_hrg_to_SEXP(const igraph_hrg_t *hrg) { igraph_error_t R_SEXP_to_hrg_copy(SEXP shrg, igraph_hrg_t *hrg) { IGRAPH_CHECK(R_SEXP_to_vector_int_copy(VECTOR_ELT(shrg, 0), &hrg->left)); - IGRAPH_FINALLY(igraph_vector_int_destroy, &hrg->left); + IGRAPH_FINALLY_PV(igraph_vector_int_destroy, &hrg->left); IGRAPH_CHECK(R_SEXP_to_vector_int_copy(VECTOR_ELT(shrg, 1), &hrg->right)); - IGRAPH_FINALLY(igraph_vector_int_destroy, &hrg->right); + IGRAPH_FINALLY_PV(igraph_vector_int_destroy, &hrg->right); IGRAPH_CHECK(R_SEXP_to_vector_copy(VECTOR_ELT(shrg, 2), &hrg->prob)); - IGRAPH_FINALLY(igraph_vector_destroy, &hrg->prob); + IGRAPH_FINALLY_PV(igraph_vector_destroy, &hrg->prob); IGRAPH_CHECK(R_SEXP_to_vector_int_copy(VECTOR_ELT(shrg, 3), &hrg->edges)); - IGRAPH_FINALLY(igraph_vector_int_destroy, &hrg->edges); + IGRAPH_FINALLY_PV(igraph_vector_int_destroy, &hrg->edges); IGRAPH_CHECK(R_SEXP_to_vector_int_copy(VECTOR_ELT(shrg, 4), &hrg->vertices)); - IGRAPH_FINALLY(igraph_vector_int_destroy, &hrg->vertices); + IGRAPH_FINALLY_PV(igraph_vector_int_destroy, &hrg->vertices); IGRAPH_FINALLY_CLEAN(5); @@ -3118,11 +3143,11 @@ SEXP R_igraph_arpack_unpack_complex(SEXP vectors, SEXP values, SEXP nev) { if (0 != R_SEXP_to_igraph_matrix_copy(vectors, &c_vectors)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_vectors); + IGRAPH_FINALLY_PV(igraph_matrix_destroy, &c_vectors); if (0 != R_SEXP_to_igraph_matrix_copy(values, &c_values)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_values); + IGRAPH_FINALLY_PV(igraph_matrix_destroy, &c_values); c_nev=REAL(nev)[0]; /* Call igraph */ IGRAPH_R_CHECK(igraph_arpack_unpack_complex(&c_vectors, &c_values, c_nev)); @@ -3131,10 +3156,10 @@ SEXP R_igraph_arpack_unpack_complex(SEXP vectors, SEXP values, SEXP nev) { PROTECT(r_result=NEW_LIST(2)); PROTECT(r_names=NEW_CHARACTER(2)); PROTECT(vectors=R_igraph_matrix_to_SEXP(&c_vectors)); - igraph_matrix_destroy(&c_vectors); + igraph_matrix_destroy_pv(&c_vectors); IGRAPH_FINALLY_CLEAN(1); PROTECT(values=R_igraph_matrix_to_SEXP(&c_values)); - igraph_matrix_destroy(&c_values); + igraph_matrix_destroy_pv(&c_values); IGRAPH_FINALLY_CLEAN(1); SET_VECTOR_ELT(r_result, 0, vectors); SET_VECTOR_ELT(r_result, 1, values); @@ -3179,10 +3204,10 @@ void R_igraph_sirlist_destroy(igraph_vector_ptr_t *sl) { igraph_integer_t n=igraph_vector_ptr_size(sl); for (igraph_integer_t i=0; itimes); - igraph_vector_int_destroy(&sir->no_s); - igraph_vector_int_destroy(&sir->no_i); - igraph_vector_int_destroy(&sir->no_r); + igraph_vector_destroy_pv(&sir->times); + igraph_vector_int_destroy_pv(&sir->no_s); + igraph_vector_int_destroy_pv(&sir->no_i); + igraph_vector_int_destroy_pv(&sir->no_r); igraph_free(sir); } igraph_vector_ptr_destroy(sl); @@ -3204,22 +3229,22 @@ SEXP R_igraph_sparsemat_to_SEXP_triplet(const igraph_sparsemat_t *sp) { igraph_vector_int_t i, j; igraph_vector_t x; igraph_vector_int_init(&i, nz); - IGRAPH_FINALLY(igraph_vector_int_destroy, &i); + IGRAPH_FINALLY_PV(igraph_vector_int_destroy, &i); igraph_vector_int_init(&j, nz); - IGRAPH_FINALLY(igraph_vector_int_destroy, &j); + IGRAPH_FINALLY_PV(igraph_vector_int_destroy, &j); igraph_vector_init(&x, nz); - IGRAPH_FINALLY(igraph_vector_destroy, &x); + IGRAPH_FINALLY_PV(igraph_vector_destroy, &x); igraph_sparsemat_getelements(sp, &j, &i, &x); SET_VECTOR_ELT(res, 2, R_igraph_vector_int_to_SEXP(&i)); SET_VECTOR_ELT(res, 3, R_igraph_vector_int_to_SEXP(&j)); SET_VECTOR_ELT(res, 4, R_igraph_vector_to_SEXP(&x)); - igraph_vector_int_destroy(&i); - igraph_vector_int_destroy(&j); - igraph_vector_destroy(&x); + igraph_vector_int_destroy_pv(&i); + igraph_vector_int_destroy_pv(&j); + igraph_vector_destroy_pv(&x); IGRAPH_FINALLY_CLEAN(3); } @@ -3841,12 +3866,12 @@ SEXP R_igraph_add_edges_manual(SEXP graph, SEXP edges) { SEXP result; R_SEXP_to_vector_int_copy(edges, &v); - IGRAPH_FINALLY(igraph_vector_int_destroy, &v); + IGRAPH_FINALLY_PV(igraph_vector_int_destroy, &v); R_SEXP_to_igraph_copy(graph, &g); - IGRAPH_FINALLY(igraph_destroy, &g); + IGRAPH_FINALLY_PV(igraph_destroy, &g); IGRAPH_R_CHECK(igraph_add_edges(&g, &v, 0)); PROTECT(result=R_igraph_to_SEXP(&g)); - igraph_vector_int_destroy(&v); + igraph_vector_int_destroy_pv(&v); IGRAPH_FINALLY_CLEAN(1); IGRAPH_I_DESTROY(&g); IGRAPH_FINALLY_CLEAN(1); @@ -3900,7 +3925,7 @@ SEXP R_igraph_neighbors(SEXP graph, SEXP pvid, SEXP pmode) { IGRAPH_R_CHECK(igraph_neighbors(&g, &neis, (igraph_integer_t) vid, mode)); PROTECT(result=R_igraph_vector_int_to_SEXP(&neis)); - igraph_vector_int_destroy(&neis); + igraph_vector_int_destroy_pv(&neis); UNPROTECT(1); return result; @@ -3921,7 +3946,7 @@ SEXP R_igraph_incident(SEXP graph, SEXP pvid, SEXP pmode) { IGRAPH_R_CHECK(igraph_incident(&g, &neis, (igraph_integer_t) vid, mode)); PROTECT(result=R_igraph_vector_int_to_SEXP(&neis)); - igraph_vector_int_destroy(&neis); + igraph_vector_int_destroy_pv(&neis); UNPROTECT(1); return result; @@ -3939,7 +3964,7 @@ SEXP R_igraph_delete_edges(SEXP graph, SEXP edges) { IGRAPH_R_CHECK(igraph_delete_edges(&g, es)); PROTECT(result=R_igraph_to_SEXP(&g)); IGRAPH_I_DESTROY(&g); - igraph_vector_int_destroy(&es_data); + igraph_vector_int_destroy_pv(&es_data); igraph_es_destroy(&es); UNPROTECT(1); @@ -3958,7 +3983,7 @@ SEXP R_igraph_delete_vertices(SEXP graph, SEXP vertices) { IGRAPH_R_CHECK(igraph_delete_vertices(&g, vs)); PROTECT(result=R_igraph_to_SEXP(&g)); IGRAPH_I_DESTROY(&g); - igraph_vector_int_destroy(&vs_data); + igraph_vector_int_destroy_pv(&vs_data); igraph_vs_destroy(&vs); UNPROTECT(1); @@ -3996,7 +4021,7 @@ SEXP R_igraph_create(SEXP edges, SEXP pn, SEXP pdirected) { IGRAPH_R_CHECK(igraph_create(&g, &v, n, directed)); PROTECT(result=R_igraph_to_SEXP(&g)); IGRAPH_I_DESTROY(&g); - igraph_vector_int_destroy(&v); + igraph_vector_int_destroy_pv(&v); UNPROTECT(1); return result; @@ -4018,8 +4043,8 @@ SEXP R_igraph_degree(SEXP graph, SEXP vids, SEXP pmode, SEXP ploops) { IGRAPH_R_CHECK(igraph_degree(&g, &res, vs, mode, loops)); PROTECT(result=R_igraph_vector_int_to_SEXP(&res)); - igraph_vector_int_destroy(&res); - igraph_vector_int_destroy(&vs_data); + igraph_vector_int_destroy_pv(&res); + igraph_vector_int_destroy_pv(&vs_data); igraph_vs_destroy(&vs); UNPROTECT(1); @@ -4068,7 +4093,7 @@ SEXP R_igraph_get_diameter(SEXP graph, SEXP pdirected, SEXP punconnected, IGRAPH_R_CHECK(igraph_diameter_dijkstra(&g, Rf_isNull(pweights) ? 0 : &weights, &dialen, 0, 0, &res, 0, directed, unconnected)); PROTECT(result=R_igraph_vector_int_to_SEXP(&res)); - igraph_vector_int_destroy(&res); + igraph_vector_int_destroy_pv(&res); UNPROTECT(1); return result; @@ -4117,7 +4142,7 @@ SEXP R_igraph_subcomponent(SEXP graph, SEXP pvertex, SEXP pmode) { IGRAPH_R_CHECK(igraph_subcomponent(&g, &res, vertex, mode)); PROTECT(result=R_igraph_vector_int_to_SEXP(&res)); - igraph_vector_int_destroy(&res); + igraph_vector_int_destroy_pv(&res); UNPROTECT(1); return result; @@ -4137,7 +4162,7 @@ SEXP R_igraph_running_mean(SEXP pdata, SEXP pbinwidth) { PROTECT(result=NEW_NUMERIC(igraph_vector_size(&res))); igraph_vector_copy_to(&res, REAL(result)); - igraph_vector_destroy(&res); + igraph_vector_destroy_pv(&res); UNPROTECT(1); return result; @@ -4157,8 +4182,8 @@ SEXP R_igraph_cocitation(SEXP graph, SEXP pvids) { IGRAPH_R_CHECK(igraph_cocitation(&g, &m, vs)); PROTECT(result=R_igraph_matrix_to_SEXP(&m)); - igraph_matrix_destroy(&m); - igraph_vector_int_destroy(&vs_data); + igraph_matrix_destroy_pv(&m); + igraph_vector_int_destroy_pv(&vs_data); igraph_vs_destroy(&vs); UNPROTECT(1); @@ -4179,8 +4204,8 @@ SEXP R_igraph_bibcoupling(SEXP graph, SEXP pvids) { IGRAPH_R_CHECK(igraph_bibcoupling(&g, &m, vs)); PROTECT(result=R_igraph_matrix_to_SEXP(&m)); - igraph_matrix_destroy(&m); - igraph_vector_int_destroy(&vs_data); + igraph_matrix_destroy_pv(&m); + igraph_vector_int_destroy_pv(&vs_data); igraph_vs_destroy(&vs); UNPROTECT(1); @@ -4269,9 +4294,9 @@ SEXP R_igraph_shortest_paths(SEXP graph, SEXP pvids, SEXP pto, break; } PROTECT(result=R_igraph_matrix_to_SEXP(&res)); - igraph_matrix_destroy(&res); - igraph_vector_int_destroy(&to_data); - igraph_vector_int_destroy(&vs_data); + igraph_matrix_destroy_pv(&res); + igraph_vector_int_destroy_pv(&to_data); + igraph_vector_int_destroy_pv(&vs_data); igraph_vs_destroy(&vs); UNPROTECT(1); @@ -4300,7 +4325,7 @@ SEXP R_igraph_barabasi_game(SEXP pn, SEXP ppower, SEXP pm, SEXP poutseq, if (have_outseq) { R_SEXP_to_vector_int_copy(poutseq, &outseq); - IGRAPH_FINALLY(igraph_vector_int_destroy, &outseq); + IGRAPH_FINALLY_PV(igraph_vector_int_destroy, &outseq); myoutseq = &outseq; } @@ -4313,7 +4338,7 @@ SEXP R_igraph_barabasi_game(SEXP pn, SEXP ppower, SEXP pm, SEXP poutseq, PROTECT(result=R_igraph_to_SEXP(&g)); if (have_outseq) { - igraph_vector_int_destroy(&outseq); + igraph_vector_int_destroy_pv(&outseq); IGRAPH_FINALLY_CLEAN(1); } IGRAPH_I_DESTROY(&g); @@ -4349,7 +4374,7 @@ SEXP R_igraph_layout_fruchterman_reingold(SEXP graph, SEXP coords, } else { igraph_matrix_init(&c_coords, 0, 0); } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_coords); + IGRAPH_FINALLY_PV(igraph_matrix_destroy, &c_coords); c_niter=(igraph_integer_t) REAL(niter)[0]; c_start_temp=REAL(start_temp)[0]; if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } @@ -4362,7 +4387,7 @@ SEXP R_igraph_layout_fruchterman_reingold(SEXP graph, SEXP coords, /* Convert output */ PROTECT(coords=R_igraph_matrix_to_SEXP(&c_coords)); - igraph_matrix_destroy(&c_coords); + igraph_matrix_destroy_pv(&c_coords); IGRAPH_FINALLY_CLEAN(1); result=coords; @@ -4399,7 +4424,7 @@ SEXP R_igraph_layout_fruchterman_reingold_3d(SEXP graph, SEXP coords, } else { igraph_matrix_init(&c_coords, 0, 0); } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_coords); + IGRAPH_FINALLY_PV(igraph_matrix_destroy, &c_coords); c_niter=(igraph_integer_t) REAL(niter)[0]; c_start_temp=REAL(start_temp)[0]; if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } @@ -4414,7 +4439,7 @@ SEXP R_igraph_layout_fruchterman_reingold_3d(SEXP graph, SEXP coords, /* Convert output */ PROTECT(coords=R_igraph_matrix_to_SEXP(&c_coords)); - igraph_matrix_destroy(&c_coords); + igraph_matrix_destroy_pv(&c_coords); IGRAPH_FINALLY_CLEAN(1); result=coords; @@ -4449,7 +4474,7 @@ SEXP R_igraph_layout_kamada_kawai(SEXP graph, SEXP coords, SEXP maxiter, } else { igraph_matrix_init(&c_coords, 0, 0); } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_coords); + IGRAPH_FINALLY_PV(igraph_matrix_destroy, &c_coords); c_maxiter=(igraph_integer_t) REAL(maxiter)[0]; c_epsilon=REAL(epsilon)[0]; c_kkconst=REAL(kkconst)[0]; @@ -4463,7 +4488,7 @@ SEXP R_igraph_layout_kamada_kawai(SEXP graph, SEXP coords, SEXP maxiter, /* Convert output */ PROTECT(coords=R_igraph_matrix_to_SEXP(&c_coords)); - igraph_matrix_destroy(&c_coords); + igraph_matrix_destroy_pv(&c_coords); IGRAPH_FINALLY_CLEAN(1); result=coords; @@ -4502,7 +4527,7 @@ SEXP R_igraph_layout_kamada_kawai_3d(SEXP graph, SEXP coords, SEXP maxiter, } else { igraph_matrix_init(&c_coords, 0, 0); } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_coords); + IGRAPH_FINALLY_PV(igraph_matrix_destroy, &c_coords); c_maxiter=(igraph_integer_t) REAL(maxiter)[0]; c_epsilon=REAL(epsilon)[0]; c_kkconst=REAL(kkconst)[0]; @@ -4518,7 +4543,7 @@ SEXP R_igraph_layout_kamada_kawai_3d(SEXP graph, SEXP coords, SEXP maxiter, /* Convert output */ PROTECT(coords=R_igraph_matrix_to_SEXP(&c_coords)); - igraph_matrix_destroy(&c_coords); + igraph_matrix_destroy_pv(&c_coords); IGRAPH_FINALLY_CLEAN(1); result=coords; @@ -4548,7 +4573,7 @@ SEXP R_igraph_layout_graphopt(SEXP graph, SEXP pniter, SEXP pcharge, } IGRAPH_R_CHECK(igraph_layout_graphopt(&g, &res, niter, charge, mass, spring_length, spring_constant, max_sa_movement, !Rf_isNull(start))); PROTECT(result=R_igraph_matrix_to_SEXP(&res)); - igraph_matrix_destroy(&res); + igraph_matrix_destroy_pv(&res); UNPROTECT(1); return result; @@ -4573,7 +4598,7 @@ SEXP R_igraph_layout_lgl(SEXP graph, SEXP pmaxiter, SEXP pmaxdelta, igraph_matrix_init(&res, 0, 0); IGRAPH_R_CHECK(igraph_layout_lgl(&g, &res, maxiter, maxdelta, area, coolexp, repulserad, cellsize, root)); PROTECT(result=R_igraph_matrix_to_SEXP(&res)); - igraph_matrix_destroy(&res); + igraph_matrix_destroy_pv(&res); UNPROTECT(1); return result; @@ -4676,7 +4701,7 @@ SEXP R_igraph_get_shortest_paths(SEXP graph, SEXP pfrom, SEXP pto, break; } - igraph_vector_int_destroy(&to_data); + igraph_vector_int_destroy_pv(&to_data); igraph_vs_destroy(&to); PROTECT(result=NEW_LIST(4)); @@ -4686,7 +4711,7 @@ SEXP R_igraph_get_shortest_paths(SEXP graph, SEXP pfrom, SEXP pto, for (igraph_integer_t i=0; i Date: Sun, 5 Jan 2025 20:30:02 +0100 Subject: [PATCH 5/5] Don't call _pv() functions directly --- src/rinterface.h | 1 + src/rinterface_extra.c | 318 +++++++++++++++++++++-------------------- 2 files changed, 161 insertions(+), 158 deletions(-) diff --git a/src/rinterface.h b/src/rinterface.h index 04e0192e37..e80a49ff99 100644 --- a/src/rinterface.h +++ b/src/rinterface.h @@ -130,6 +130,7 @@ igraph_error_t R_SEXP_to_attr_comb(SEXP input, igraph_attribute_combination_t *c IGRAPH_FINALLY_REAL((func##_pv), (ptr)); \ } while (0) +// These functions are never meant to be called directly, only through IGRAPH_FINALLY_PV. void igraph_destroy_pv(void *pv_ptr); void igraph_matrix_destroy_pv(void *pv_ptr); void igraph_vector_destroy_pv(void *pv_ptr); diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 2014abe438..821e92985c 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -99,6 +99,8 @@ void R_check_bool_scalar(SEXP value) } } +// These functions are never meant to be called directly, only through IGRAPH_FINALLY_PV. + void igraph_destroy_pv(void* pv_ptr) { igraph_destroy((igraph_t*) pv_ptr); @@ -650,7 +652,7 @@ igraph_error_t R_igraph_attribute_add_vertices(igraph_t *graph, igraph_integer_t val=VECTOR_ELT(attr, 2); UNPROTECT(9); } - igraph_vector_int_destroy_pv(&news); + igraph_vector_int_destroy(&news); IGRAPH_FINALLY_CLEAN(1); /* news */ /* Now append the new values */ @@ -987,7 +989,7 @@ igraph_error_t R_igraph_attribute_add_edges(igraph_t *graph, const igraph_vector eal=VECTOR_ELT(attr, 3); UNPROTECT(9); } - igraph_vector_int_destroy_pv(&news); + igraph_vector_int_destroy(&news); IGRAPH_FINALLY_CLEAN(1); /* Now append the new values */ @@ -1312,7 +1314,7 @@ igraph_error_t R_igraph_attribute_get_numeric_vertex_attr(const igraph_t *graph, if (igraph_vs_is_all(&vs)) { R_SEXP_to_vector_copy(AS_NUMERIC(va), &newvalue); - igraph_vector_destroy_pv(value); + igraph_vector_destroy(value); *value=newvalue; } else { igraph_vit_t it; @@ -1360,7 +1362,7 @@ igraph_error_t R_igraph_attribute_get_bool_vertex_attr(const igraph_t *graph, if (igraph_vs_is_all(&vs)) { R_SEXP_to_vector_bool_copy(va, &newvalue); - igraph_vector_bool_destroy_pv(value); + igraph_vector_bool_destroy(value); *value=newvalue; } else { igraph_vit_t it; @@ -1437,7 +1439,7 @@ igraph_error_t R_igraph_attribute_get_numeric_edge_attr(const igraph_t *graph, if (igraph_es_is_all(&es)) { R_SEXP_to_vector_copy(AS_NUMERIC(ea), &newvalue); - igraph_vector_destroy_pv(value); + igraph_vector_destroy(value); *value=newvalue; } else { igraph_eit_t it; @@ -1485,7 +1487,7 @@ igraph_error_t R_igraph_attribute_get_bool_edge_attr(const igraph_t *graph, if (igraph_es_is_all(&es)) { R_SEXP_to_vector_bool_copy(ea, &newvalue); - igraph_vector_bool_destroy_pv(value); + igraph_vector_bool_destroy(value); *value=newvalue; } else { igraph_eit_t it; @@ -2575,7 +2577,7 @@ SEXP R_igraph_0orvector_int_to_SEXP_d(igraph_vector_int_t *v) { SEXP result; if (v) { PROTECT(result=R_igraph_vector_int_to_SEXP(v)); - igraph_vector_int_destroy_pv(v); + igraph_vector_int_destroy(v); } else { PROTECT(result=R_NilValue); } @@ -2841,9 +2843,9 @@ static igraph_error_t restore_pointer(SEXP graph, igraph_t *g) { IGRAPH_FINALLY_PV(igraph_destroy, g); IGRAPH_CHECK(igraph_add_edges(g, &edges, NULL)); - igraph_vector_int_destroy_pv(&from); - igraph_vector_int_destroy_pv(&to); - igraph_vector_int_destroy_pv(&edges); + igraph_vector_int_destroy(&from); + igraph_vector_int_destroy(&to); + igraph_vector_int_destroy(&edges); IGRAPH_FINALLY_CLEAN(4); /* +1 for g */ return IGRAPH_SUCCESS; @@ -3156,10 +3158,10 @@ SEXP R_igraph_arpack_unpack_complex(SEXP vectors, SEXP values, SEXP nev) { PROTECT(r_result=NEW_LIST(2)); PROTECT(r_names=NEW_CHARACTER(2)); PROTECT(vectors=R_igraph_matrix_to_SEXP(&c_vectors)); - igraph_matrix_destroy_pv(&c_vectors); + igraph_matrix_destroy(&c_vectors); IGRAPH_FINALLY_CLEAN(1); PROTECT(values=R_igraph_matrix_to_SEXP(&c_values)); - igraph_matrix_destroy_pv(&c_values); + igraph_matrix_destroy(&c_values); IGRAPH_FINALLY_CLEAN(1); SET_VECTOR_ELT(r_result, 0, vectors); SET_VECTOR_ELT(r_result, 1, values); @@ -3204,10 +3206,10 @@ void R_igraph_sirlist_destroy(igraph_vector_ptr_t *sl) { igraph_integer_t n=igraph_vector_ptr_size(sl); for (igraph_integer_t i=0; itimes); - igraph_vector_int_destroy_pv(&sir->no_s); - igraph_vector_int_destroy_pv(&sir->no_i); - igraph_vector_int_destroy_pv(&sir->no_r); + igraph_vector_destroy(&sir->times); + igraph_vector_int_destroy(&sir->no_s); + igraph_vector_int_destroy(&sir->no_i); + igraph_vector_int_destroy(&sir->no_r); igraph_free(sir); } igraph_vector_ptr_destroy(sl); @@ -3242,9 +3244,9 @@ SEXP R_igraph_sparsemat_to_SEXP_triplet(const igraph_sparsemat_t *sp) { SET_VECTOR_ELT(res, 3, R_igraph_vector_int_to_SEXP(&j)); SET_VECTOR_ELT(res, 4, R_igraph_vector_to_SEXP(&x)); - igraph_vector_int_destroy_pv(&i); - igraph_vector_int_destroy_pv(&j); - igraph_vector_destroy_pv(&x); + igraph_vector_int_destroy(&i); + igraph_vector_int_destroy(&j); + igraph_vector_destroy(&x); IGRAPH_FINALLY_CLEAN(3); } @@ -3871,7 +3873,7 @@ SEXP R_igraph_add_edges_manual(SEXP graph, SEXP edges) { IGRAPH_FINALLY_PV(igraph_destroy, &g); IGRAPH_R_CHECK(igraph_add_edges(&g, &v, 0)); PROTECT(result=R_igraph_to_SEXP(&g)); - igraph_vector_int_destroy_pv(&v); + igraph_vector_int_destroy(&v); IGRAPH_FINALLY_CLEAN(1); IGRAPH_I_DESTROY(&g); IGRAPH_FINALLY_CLEAN(1); @@ -3925,7 +3927,7 @@ SEXP R_igraph_neighbors(SEXP graph, SEXP pvid, SEXP pmode) { IGRAPH_R_CHECK(igraph_neighbors(&g, &neis, (igraph_integer_t) vid, mode)); PROTECT(result=R_igraph_vector_int_to_SEXP(&neis)); - igraph_vector_int_destroy_pv(&neis); + igraph_vector_int_destroy(&neis); UNPROTECT(1); return result; @@ -3946,7 +3948,7 @@ SEXP R_igraph_incident(SEXP graph, SEXP pvid, SEXP pmode) { IGRAPH_R_CHECK(igraph_incident(&g, &neis, (igraph_integer_t) vid, mode)); PROTECT(result=R_igraph_vector_int_to_SEXP(&neis)); - igraph_vector_int_destroy_pv(&neis); + igraph_vector_int_destroy(&neis); UNPROTECT(1); return result; @@ -3964,7 +3966,7 @@ SEXP R_igraph_delete_edges(SEXP graph, SEXP edges) { IGRAPH_R_CHECK(igraph_delete_edges(&g, es)); PROTECT(result=R_igraph_to_SEXP(&g)); IGRAPH_I_DESTROY(&g); - igraph_vector_int_destroy_pv(&es_data); + igraph_vector_int_destroy(&es_data); igraph_es_destroy(&es); UNPROTECT(1); @@ -3983,7 +3985,7 @@ SEXP R_igraph_delete_vertices(SEXP graph, SEXP vertices) { IGRAPH_R_CHECK(igraph_delete_vertices(&g, vs)); PROTECT(result=R_igraph_to_SEXP(&g)); IGRAPH_I_DESTROY(&g); - igraph_vector_int_destroy_pv(&vs_data); + igraph_vector_int_destroy(&vs_data); igraph_vs_destroy(&vs); UNPROTECT(1); @@ -4021,7 +4023,7 @@ SEXP R_igraph_create(SEXP edges, SEXP pn, SEXP pdirected) { IGRAPH_R_CHECK(igraph_create(&g, &v, n, directed)); PROTECT(result=R_igraph_to_SEXP(&g)); IGRAPH_I_DESTROY(&g); - igraph_vector_int_destroy_pv(&v); + igraph_vector_int_destroy(&v); UNPROTECT(1); return result; @@ -4043,8 +4045,8 @@ SEXP R_igraph_degree(SEXP graph, SEXP vids, SEXP pmode, SEXP ploops) { IGRAPH_R_CHECK(igraph_degree(&g, &res, vs, mode, loops)); PROTECT(result=R_igraph_vector_int_to_SEXP(&res)); - igraph_vector_int_destroy_pv(&res); - igraph_vector_int_destroy_pv(&vs_data); + igraph_vector_int_destroy(&res); + igraph_vector_int_destroy(&vs_data); igraph_vs_destroy(&vs); UNPROTECT(1); @@ -4093,7 +4095,7 @@ SEXP R_igraph_get_diameter(SEXP graph, SEXP pdirected, SEXP punconnected, IGRAPH_R_CHECK(igraph_diameter_dijkstra(&g, Rf_isNull(pweights) ? 0 : &weights, &dialen, 0, 0, &res, 0, directed, unconnected)); PROTECT(result=R_igraph_vector_int_to_SEXP(&res)); - igraph_vector_int_destroy_pv(&res); + igraph_vector_int_destroy(&res); UNPROTECT(1); return result; @@ -4142,7 +4144,7 @@ SEXP R_igraph_subcomponent(SEXP graph, SEXP pvertex, SEXP pmode) { IGRAPH_R_CHECK(igraph_subcomponent(&g, &res, vertex, mode)); PROTECT(result=R_igraph_vector_int_to_SEXP(&res)); - igraph_vector_int_destroy_pv(&res); + igraph_vector_int_destroy(&res); UNPROTECT(1); return result; @@ -4162,7 +4164,7 @@ SEXP R_igraph_running_mean(SEXP pdata, SEXP pbinwidth) { PROTECT(result=NEW_NUMERIC(igraph_vector_size(&res))); igraph_vector_copy_to(&res, REAL(result)); - igraph_vector_destroy_pv(&res); + igraph_vector_destroy(&res); UNPROTECT(1); return result; @@ -4182,8 +4184,8 @@ SEXP R_igraph_cocitation(SEXP graph, SEXP pvids) { IGRAPH_R_CHECK(igraph_cocitation(&g, &m, vs)); PROTECT(result=R_igraph_matrix_to_SEXP(&m)); - igraph_matrix_destroy_pv(&m); - igraph_vector_int_destroy_pv(&vs_data); + igraph_matrix_destroy(&m); + igraph_vector_int_destroy(&vs_data); igraph_vs_destroy(&vs); UNPROTECT(1); @@ -4204,8 +4206,8 @@ SEXP R_igraph_bibcoupling(SEXP graph, SEXP pvids) { IGRAPH_R_CHECK(igraph_bibcoupling(&g, &m, vs)); PROTECT(result=R_igraph_matrix_to_SEXP(&m)); - igraph_matrix_destroy_pv(&m); - igraph_vector_int_destroy_pv(&vs_data); + igraph_matrix_destroy(&m); + igraph_vector_int_destroy(&vs_data); igraph_vs_destroy(&vs); UNPROTECT(1); @@ -4294,9 +4296,9 @@ SEXP R_igraph_shortest_paths(SEXP graph, SEXP pvids, SEXP pto, break; } PROTECT(result=R_igraph_matrix_to_SEXP(&res)); - igraph_matrix_destroy_pv(&res); - igraph_vector_int_destroy_pv(&to_data); - igraph_vector_int_destroy_pv(&vs_data); + igraph_matrix_destroy(&res); + igraph_vector_int_destroy(&to_data); + igraph_vector_int_destroy(&vs_data); igraph_vs_destroy(&vs); UNPROTECT(1); @@ -4338,7 +4340,7 @@ SEXP R_igraph_barabasi_game(SEXP pn, SEXP ppower, SEXP pm, SEXP poutseq, PROTECT(result=R_igraph_to_SEXP(&g)); if (have_outseq) { - igraph_vector_int_destroy_pv(&outseq); + igraph_vector_int_destroy(&outseq); IGRAPH_FINALLY_CLEAN(1); } IGRAPH_I_DESTROY(&g); @@ -4387,7 +4389,7 @@ SEXP R_igraph_layout_fruchterman_reingold(SEXP graph, SEXP coords, /* Convert output */ PROTECT(coords=R_igraph_matrix_to_SEXP(&c_coords)); - igraph_matrix_destroy_pv(&c_coords); + igraph_matrix_destroy(&c_coords); IGRAPH_FINALLY_CLEAN(1); result=coords; @@ -4439,7 +4441,7 @@ SEXP R_igraph_layout_fruchterman_reingold_3d(SEXP graph, SEXP coords, /* Convert output */ PROTECT(coords=R_igraph_matrix_to_SEXP(&c_coords)); - igraph_matrix_destroy_pv(&c_coords); + igraph_matrix_destroy(&c_coords); IGRAPH_FINALLY_CLEAN(1); result=coords; @@ -4488,7 +4490,7 @@ SEXP R_igraph_layout_kamada_kawai(SEXP graph, SEXP coords, SEXP maxiter, /* Convert output */ PROTECT(coords=R_igraph_matrix_to_SEXP(&c_coords)); - igraph_matrix_destroy_pv(&c_coords); + igraph_matrix_destroy(&c_coords); IGRAPH_FINALLY_CLEAN(1); result=coords; @@ -4543,7 +4545,7 @@ SEXP R_igraph_layout_kamada_kawai_3d(SEXP graph, SEXP coords, SEXP maxiter, /* Convert output */ PROTECT(coords=R_igraph_matrix_to_SEXP(&c_coords)); - igraph_matrix_destroy_pv(&c_coords); + igraph_matrix_destroy(&c_coords); IGRAPH_FINALLY_CLEAN(1); result=coords; @@ -4573,7 +4575,7 @@ SEXP R_igraph_layout_graphopt(SEXP graph, SEXP pniter, SEXP pcharge, } IGRAPH_R_CHECK(igraph_layout_graphopt(&g, &res, niter, charge, mass, spring_length, spring_constant, max_sa_movement, !Rf_isNull(start))); PROTECT(result=R_igraph_matrix_to_SEXP(&res)); - igraph_matrix_destroy_pv(&res); + igraph_matrix_destroy(&res); UNPROTECT(1); return result; @@ -4598,7 +4600,7 @@ SEXP R_igraph_layout_lgl(SEXP graph, SEXP pmaxiter, SEXP pmaxdelta, igraph_matrix_init(&res, 0, 0); IGRAPH_R_CHECK(igraph_layout_lgl(&g, &res, maxiter, maxdelta, area, coolexp, repulserad, cellsize, root)); PROTECT(result=R_igraph_matrix_to_SEXP(&res)); - igraph_matrix_destroy_pv(&res); + igraph_matrix_destroy(&res); UNPROTECT(1); return result; @@ -4701,7 +4703,7 @@ SEXP R_igraph_get_shortest_paths(SEXP graph, SEXP pfrom, SEXP pto, break; } - igraph_vector_int_destroy_pv(&to_data); + igraph_vector_int_destroy(&to_data); igraph_vs_destroy(&to); PROTECT(result=NEW_LIST(4)); @@ -4711,7 +4713,7 @@ SEXP R_igraph_get_shortest_paths(SEXP graph, SEXP pfrom, SEXP pto, for (igraph_integer_t i=0; i