From ada67cdb7d276f268d4d694eb2e2b00b58d8c19f Mon Sep 17 00:00:00 2001 From: Antonov548 Date: Wed, 14 Jun 2023 16:00:11 +0200 Subject: [PATCH 1/2] copy integer vector in output --- src/rinterface.c | 66 +++++++++++++++++----------------- src/rinterface_extra.c | 19 +++++----- tools/stimulus/rinterface.c.in | 2 +- tools/stimulus/types-RC.yaml | 8 ++--- 4 files changed, 49 insertions(+), 46 deletions(-) diff --git a/src/rinterface.c b/src/rinterface.c index ddb872b8042..8e6711476a9 100644 --- a/src/rinterface.c +++ b/src/rinterface.c @@ -106,7 +106,7 @@ int R_igraph_SEXP_to_vectorlist_int(SEXP vectorlist, int R_igraph_SEXP_to_matrixlist(SEXP matrixlist, igraph_vector_ptr_t *ptr); int R_SEXP_to_vector_bool(SEXP sv, igraph_vector_bool_t *v); int R_SEXP_to_vector_bool_copy(SEXP sv, igraph_vector_bool_t *v); -int R_SEXP_to_vector_int(SEXP sv, igraph_vector_int_t *v); +int R_SEXP_to_vector_int_copy(SEXP sv, igraph_vector_int_t *v); int R_SEXP_to_vector_long_copy(SEXP sv, igraph_vector_long_t *v); int R_SEXP_to_hrg(SEXP shrg, igraph_hrg_t *hrg); int R_SEXP_to_hrg_copy(SEXP shrg, igraph_hrg_t *hrg); @@ -711,7 +711,7 @@ SEXP R_igraph_sbm_game(SEXP n, SEXP pref_matrix, SEXP block_sizes, SEXP directed /* Convert input */ c_n=INTEGER(n)[0]; R_SEXP_to_matrix(pref_matrix, &c_pref_matrix); - R_SEXP_to_vector_int(block_sizes, &c_block_sizes); + R_SEXP_to_vector_int_copy(block_sizes, &c_block_sizes); c_directed=LOGICAL(directed)[0]; c_loops=LOGICAL(loops)[0]; /* Call igraph */ @@ -778,7 +778,7 @@ SEXP R_igraph_hsbm_list_game(SEXP n, SEXP mlist, SEXP rholist, SEXP Clist, SEXP SEXP r_result; /* Convert input */ c_n=INTEGER(n)[0]; - R_SEXP_to_vector_int(mlist, &c_mlist); + R_SEXP_to_vector_int_copy(mlist, &c_mlist); R_igraph_SEXP_to_vectorlist(rholist, &c_rholist); R_igraph_SEXP_to_matrixlist(Clist, &c_Clist); c_p=REAL(p)[0]; @@ -6103,10 +6103,10 @@ SEXP R_igraph_isomorphic_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SEXP /* Convert input */ R_SEXP_to_igraph(graph1, &c_graph1); R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int(vertex_color1, &c_vertex_color1); } - if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int(vertex_color2, &c_vertex_color2); } - if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int(edge_color1, &c_edge_color1); } - if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int(edge_color2, &c_edge_color2); } + if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); } + if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); } + if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); } + if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); } if (0 != igraph_vector_init(&c_map12, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } @@ -6165,10 +6165,10 @@ SEXP R_igraph_count_isomorphisms_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color /* Convert input */ R_SEXP_to_igraph(graph1, &c_graph1); R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int(vertex_color1, &c_vertex_color1); } - if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int(vertex_color2, &c_vertex_color2); } - if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int(edge_color1, &c_edge_color1); } - if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int(edge_color2, &c_edge_color2); } + if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); } + if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); } + if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); } + if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); } c_count=0; /* Call igraph */ IGRAPH_R_CHECK(igraph_count_isomorphisms_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_count, 0, 0, 0)); @@ -6203,10 +6203,10 @@ SEXP R_igraph_get_isomorphisms_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, /* Convert input */ R_SEXP_to_igraph(graph1, &c_graph1); R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int(vertex_color1, &c_vertex_color1); } - if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int(vertex_color2, &c_vertex_color2); } - if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int(edge_color1, &c_edge_color1); } - if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int(edge_color2, &c_edge_color2); } + if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); } + if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); } + if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); } + if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); } if (0 != igraph_vector_ptr_init(&c_maps, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } @@ -6249,10 +6249,10 @@ SEXP R_igraph_subisomorphic_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SE /* Convert input */ R_SEXP_to_igraph(graph1, &c_graph1); R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int(vertex_color1, &c_vertex_color1); } - if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int(vertex_color2, &c_vertex_color2); } - if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int(edge_color1, &c_edge_color1); } - if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int(edge_color2, &c_edge_color2); } + if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); } + if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); } + if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); } + if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); } if (0 != igraph_vector_init(&c_map12, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } @@ -6311,10 +6311,10 @@ SEXP R_igraph_count_subisomorphisms_vf2(SEXP graph1, SEXP graph2, SEXP vertex_co /* Convert input */ R_SEXP_to_igraph(graph1, &c_graph1); R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int(vertex_color1, &c_vertex_color1); } - if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int(vertex_color2, &c_vertex_color2); } - if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int(edge_color1, &c_edge_color1); } - if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int(edge_color2, &c_edge_color2); } + if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); } + if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); } + if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); } + if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); } c_count=0; /* Call igraph */ IGRAPH_R_CHECK(igraph_count_subisomorphisms_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_count, 0, 0, 0)); @@ -6349,10 +6349,10 @@ SEXP R_igraph_get_subisomorphisms_vf2(SEXP graph1, SEXP graph2, SEXP vertex_colo /* Convert input */ R_SEXP_to_igraph(graph1, &c_graph1); R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int(vertex_color1, &c_vertex_color1); } - if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int(vertex_color2, &c_vertex_color2); } - if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int(edge_color1, &c_edge_color1); } - if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int(edge_color2, &c_edge_color2); } + if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); } + if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); } + if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); } + if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); } if (0 != igraph_vector_ptr_init(&c_maps, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } @@ -6412,7 +6412,7 @@ SEXP R_igraph_canonical_permutation(SEXP graph, SEXP colors, SEXP sh) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(colors)) { R_SEXP_to_vector_int(colors, &c_colors); } + if (!Rf_isNull(colors)) { R_SEXP_to_vector_int_copy(colors, &c_colors); } if (0 != igraph_vector_init(&c_labeling, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } @@ -6493,8 +6493,8 @@ SEXP R_igraph_isomorphic_bliss(SEXP graph1, SEXP graph2, SEXP colors1, SEXP colo /* Convert input */ R_SEXP_to_igraph(graph1, &c_graph1); R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(colors1)) { R_SEXP_to_vector_int(colors1, &c_colors1); } - if (!Rf_isNull(colors2)) { R_SEXP_to_vector_int(colors2, &c_colors2); } + if (!Rf_isNull(colors1)) { R_SEXP_to_vector_int_copy(colors1, &c_colors1); } + if (!Rf_isNull(colors2)) { R_SEXP_to_vector_int_copy(colors2, &c_colors2); } if (0 != igraph_vector_init(&c_map12, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } @@ -6555,7 +6555,7 @@ SEXP R_igraph_automorphisms(SEXP graph, SEXP colors, SEXP sh) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(colors)) { R_SEXP_to_vector_int(colors, &c_colors); } + if (!Rf_isNull(colors)) { R_SEXP_to_vector_int_copy(colors, &c_colors); } c_sh = (igraph_bliss_sh_t) Rf_asInteger(sh); /* Call igraph */ IGRAPH_R_CHECK(igraph_automorphisms(&c_graph, (Rf_isNull(colors) ? 0 : &c_colors), c_sh, &c_info)); @@ -6585,7 +6585,7 @@ SEXP R_igraph_automorphism_group(SEXP graph, SEXP colors, SEXP sh) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(colors)) { R_SEXP_to_vector_int(colors, &c_colors); } + if (!Rf_isNull(colors)) { R_SEXP_to_vector_int_copy(colors, &c_colors); } if (0 != igraph_vector_ptr_init(&c_generators, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } @@ -7240,7 +7240,7 @@ SEXP R_igraph_from_prufer(SEXP prufer) { SEXP r_result; /* Convert input */ - R_SEXP_to_vector_int(prufer, &c_prufer); + R_SEXP_to_vector_int_copy(prufer, &c_prufer); /* Call igraph */ IGRAPH_R_CHECK(igraph_from_prufer(&c_graph, &c_prufer)); diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 84d943a791f..7e942d8b9bf 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -107,7 +107,7 @@ int R_igraph_SEXP_to_vectorlist_int(SEXP vectorlist, int R_igraph_SEXP_to_matrixlist(SEXP matrixlist, igraph_vector_ptr_t *ptr); int R_SEXP_to_vector_bool(SEXP sv, igraph_vector_bool_t *v); int R_SEXP_to_vector_bool_copy(SEXP sv, igraph_vector_bool_t *v); -int R_SEXP_to_vector_int(SEXP sv, igraph_vector_int_t *v); +int R_SEXP_to_vector_int_copy(SEXP sv, igraph_vector_int_t *v); int R_SEXP_to_vector_long_copy(SEXP sv, igraph_vector_long_t *v); int R_SEXP_to_hrg(SEXP shrg, igraph_hrg_t *hrg); int R_SEXP_to_hrg_copy(SEXP shrg, igraph_hrg_t *hrg); @@ -3604,10 +3604,13 @@ int R_SEXP_to_vector_bool_copy(SEXP sv, igraph_vector_bool_t *v) { return 0; } -int R_SEXP_to_vector_int(SEXP sv, igraph_vector_int_t *v) { - v->stor_begin=(int*) INTEGER(sv); - v->stor_end=v->stor_begin+GET_LENGTH(sv); - v->end=v->stor_end; +int R_SEXP_to_vector_int_copy(SEXP sv, igraph_vector_int_t *v) { + long int i, n=GET_LENGTH(sv); + int *svv=INTEGER(sv); + igraph_vector_int_init(v, n); + for (i = 0; i Date: Thu, 15 Jun 2023 09:23:08 +0200 Subject: [PATCH 2/2] add `destroy` --- src/rinterface.c | 276 ++++++++++++++++++++++++++++++++++++----- src/rinterface_extra.c | 27 +++- 2 files changed, 270 insertions(+), 33 deletions(-) diff --git a/src/rinterface.c b/src/rinterface.c index 8e6711476a9..23cbfc212ec 100644 --- a/src/rinterface.c +++ b/src/rinterface.c @@ -712,6 +712,7 @@ SEXP R_igraph_sbm_game(SEXP n, SEXP pref_matrix, SEXP block_sizes, SEXP directed c_n=INTEGER(n)[0]; R_SEXP_to_matrix(pref_matrix, &c_pref_matrix); R_SEXP_to_vector_int_copy(block_sizes, &c_block_sizes); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_block_sizes); c_directed=LOGICAL(directed)[0]; c_loops=LOGICAL(loops)[0]; /* Call igraph */ @@ -722,6 +723,8 @@ SEXP R_igraph_sbm_game(SEXP n, SEXP pref_matrix, SEXP block_sizes, SEXP directed PROTECT(graph=R_igraph_to_SEXP(&c_graph)); IGRAPH_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_block_sizes); + IGRAPH_FINALLY_CLEAN(1); r_result = graph; UNPROTECT(1); @@ -779,6 +782,7 @@ SEXP R_igraph_hsbm_list_game(SEXP n, SEXP mlist, SEXP rholist, SEXP Clist, SEXP /* Convert input */ c_n=INTEGER(n)[0]; R_SEXP_to_vector_int_copy(mlist, &c_mlist); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_mlist); R_igraph_SEXP_to_vectorlist(rholist, &c_rholist); R_igraph_SEXP_to_matrixlist(Clist, &c_Clist); c_p=REAL(p)[0]; @@ -790,6 +794,8 @@ SEXP R_igraph_hsbm_list_game(SEXP n, SEXP mlist, SEXP rholist, SEXP Clist, SEXP PROTECT(graph=R_igraph_to_SEXP(&c_graph)); IGRAPH_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_mlist); + IGRAPH_FINALLY_CLEAN(1); r_result = graph; UNPROTECT(1); @@ -6103,10 +6109,30 @@ SEXP R_igraph_isomorphic_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SEXP /* Convert input */ R_SEXP_to_igraph(graph1, &c_graph1); R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); } - if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); } - if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); } - if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); } + if (!Rf_isNull(vertex_color1)) { + R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); + if (!Rf_isNull(vertex_color2)) { + R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); + if (!Rf_isNull(edge_color1)) { + R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color1); + if (!Rf_isNull(edge_color2)) { + R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color2); if (0 != igraph_vector_init(&c_map12, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } @@ -6123,6 +6149,14 @@ SEXP R_igraph_isomorphic_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SEXP /* Convert output */ PROTECT(r_result=NEW_LIST(3)); PROTECT(r_names=NEW_CHARACTER(3)); + igraph_vector_int_destroy(&c_vertex_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_vertex_color2); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color2); + IGRAPH_FINALLY_CLEAN(1); PROTECT(iso=NEW_LOGICAL(1)); LOGICAL(iso)[0]=c_iso; PROTECT(map12=R_igraph_0orvector_to_SEXPp1(&c_map12)); @@ -6165,15 +6199,43 @@ SEXP R_igraph_count_isomorphisms_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color /* Convert input */ R_SEXP_to_igraph(graph1, &c_graph1); R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); } - if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); } - if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); } - if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); } + if (!Rf_isNull(vertex_color1)) { + R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); + if (!Rf_isNull(vertex_color2)) { + R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); + if (!Rf_isNull(edge_color1)) { + R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color1); + if (!Rf_isNull(edge_color2)) { + R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color2); c_count=0; /* Call igraph */ IGRAPH_R_CHECK(igraph_count_isomorphisms_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_count, 0, 0, 0)); /* Convert output */ + igraph_vector_int_destroy(&c_vertex_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_vertex_color2); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color2); + IGRAPH_FINALLY_CLEAN(1); PROTECT(count=NEW_INTEGER(1)); INTEGER(count)[0]=c_count; r_result = count; @@ -6203,10 +6265,30 @@ SEXP R_igraph_get_isomorphisms_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, /* Convert input */ R_SEXP_to_igraph(graph1, &c_graph1); R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); } - if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); } - if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); } - if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); } + if (!Rf_isNull(vertex_color1)) { + R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); + if (!Rf_isNull(vertex_color2)) { + R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); + if (!Rf_isNull(edge_color1)) { + R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color1); + if (!Rf_isNull(edge_color2)) { + R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color2); if (0 != igraph_vector_ptr_init(&c_maps, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } @@ -6215,6 +6297,14 @@ SEXP R_igraph_get_isomorphisms_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, IGRAPH_R_CHECK(igraph_get_isomorphisms_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_maps, 0, 0, 0)); /* Convert output */ + igraph_vector_int_destroy(&c_vertex_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_vertex_color2); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color2); + IGRAPH_FINALLY_CLEAN(1); PROTECT(maps=R_igraph_vectorlist_to_SEXP(&c_maps)); R_igraph_vectorlist_destroy(&c_maps); IGRAPH_FINALLY_CLEAN(1); @@ -6249,10 +6339,30 @@ SEXP R_igraph_subisomorphic_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SE /* Convert input */ R_SEXP_to_igraph(graph1, &c_graph1); R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); } - if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); } - if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); } - if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); } + if (!Rf_isNull(vertex_color1)) { + R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); + if (!Rf_isNull(vertex_color2)) { + R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); + if (!Rf_isNull(edge_color1)) { + R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color1); + if (!Rf_isNull(edge_color2)) { + R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color2); if (0 != igraph_vector_init(&c_map12, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } @@ -6269,6 +6379,14 @@ SEXP R_igraph_subisomorphic_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SE /* Convert output */ PROTECT(r_result=NEW_LIST(3)); PROTECT(r_names=NEW_CHARACTER(3)); + igraph_vector_int_destroy(&c_vertex_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_vertex_color2); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color2); + IGRAPH_FINALLY_CLEAN(1); PROTECT(iso=NEW_LOGICAL(1)); LOGICAL(iso)[0]=c_iso; PROTECT(map12=R_igraph_0orvector_to_SEXPp1(&c_map12)); @@ -6311,15 +6429,43 @@ SEXP R_igraph_count_subisomorphisms_vf2(SEXP graph1, SEXP graph2, SEXP vertex_co /* Convert input */ R_SEXP_to_igraph(graph1, &c_graph1); R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); } - if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); } - if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); } - if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); } + if (!Rf_isNull(vertex_color1)) { + R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); + if (!Rf_isNull(vertex_color2)) { + R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); + if (!Rf_isNull(edge_color1)) { + R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color1); + if (!Rf_isNull(edge_color2)) { + R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color2); c_count=0; /* Call igraph */ IGRAPH_R_CHECK(igraph_count_subisomorphisms_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_count, 0, 0, 0)); /* Convert output */ + igraph_vector_int_destroy(&c_vertex_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_vertex_color2); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color2); + IGRAPH_FINALLY_CLEAN(1); PROTECT(count=NEW_INTEGER(1)); INTEGER(count)[0]=c_count; r_result = count; @@ -6349,10 +6495,30 @@ SEXP R_igraph_get_subisomorphisms_vf2(SEXP graph1, SEXP graph2, SEXP vertex_colo /* Convert input */ R_SEXP_to_igraph(graph1, &c_graph1); R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); } - if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); } - if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); } - if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); } + if (!Rf_isNull(vertex_color1)) { + R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); + if (!Rf_isNull(vertex_color2)) { + R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); + if (!Rf_isNull(edge_color1)) { + R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color1); + if (!Rf_isNull(edge_color2)) { + R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color2); if (0 != igraph_vector_ptr_init(&c_maps, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } @@ -6361,6 +6527,14 @@ SEXP R_igraph_get_subisomorphisms_vf2(SEXP graph1, SEXP graph2, SEXP vertex_colo IGRAPH_R_CHECK(igraph_get_subisomorphisms_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_maps, 0, 0, 0)); /* Convert output */ + igraph_vector_int_destroy(&c_vertex_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_vertex_color2); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color2); + IGRAPH_FINALLY_CLEAN(1); PROTECT(maps=R_igraph_vectorlist_to_SEXP(&c_maps)); R_igraph_vectorlist_destroy(&c_maps); IGRAPH_FINALLY_CLEAN(1); @@ -6412,7 +6586,12 @@ SEXP R_igraph_canonical_permutation(SEXP graph, SEXP colors, SEXP sh) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(colors)) { R_SEXP_to_vector_int_copy(colors, &c_colors); } + if (!Rf_isNull(colors)) { + R_SEXP_to_vector_int_copy(colors, &c_colors); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_colors, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_colors); if (0 != igraph_vector_init(&c_labeling, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } @@ -6424,6 +6603,8 @@ SEXP R_igraph_canonical_permutation(SEXP graph, SEXP colors, SEXP sh) { /* Convert output */ PROTECT(r_result=NEW_LIST(2)); PROTECT(r_names=NEW_CHARACTER(2)); + igraph_vector_int_destroy(&c_colors); + IGRAPH_FINALLY_CLEAN(1); PROTECT(labeling=R_igraph_vector_to_SEXPp1(&c_labeling)); igraph_vector_destroy(&c_labeling); IGRAPH_FINALLY_CLEAN(1); @@ -6493,8 +6674,18 @@ SEXP R_igraph_isomorphic_bliss(SEXP graph1, SEXP graph2, SEXP colors1, SEXP colo /* Convert input */ R_SEXP_to_igraph(graph1, &c_graph1); R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(colors1)) { R_SEXP_to_vector_int_copy(colors1, &c_colors1); } - if (!Rf_isNull(colors2)) { R_SEXP_to_vector_int_copy(colors2, &c_colors2); } + if (!Rf_isNull(colors1)) { + R_SEXP_to_vector_int_copy(colors1, &c_colors1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_colors1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_colors1); + if (!Rf_isNull(colors2)) { + R_SEXP_to_vector_int_copy(colors2, &c_colors2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_colors2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_colors2); if (0 != igraph_vector_init(&c_map12, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } @@ -6512,6 +6703,10 @@ SEXP R_igraph_isomorphic_bliss(SEXP graph1, SEXP graph2, SEXP colors1, SEXP colo /* Convert output */ PROTECT(r_result=NEW_LIST(5)); PROTECT(r_names=NEW_CHARACTER(5)); + igraph_vector_int_destroy(&c_colors1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_colors2); + IGRAPH_FINALLY_CLEAN(1); PROTECT(iso=NEW_LOGICAL(1)); LOGICAL(iso)[0]=c_iso; PROTECT(map12=R_igraph_0orvector_to_SEXPp1(&c_map12)); @@ -6555,12 +6750,19 @@ SEXP R_igraph_automorphisms(SEXP graph, SEXP colors, SEXP sh) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(colors)) { R_SEXP_to_vector_int_copy(colors, &c_colors); } + if (!Rf_isNull(colors)) { + R_SEXP_to_vector_int_copy(colors, &c_colors); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_colors, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_colors); c_sh = (igraph_bliss_sh_t) Rf_asInteger(sh); /* Call igraph */ IGRAPH_R_CHECK(igraph_automorphisms(&c_graph, (Rf_isNull(colors) ? 0 : &c_colors), c_sh, &c_info)); /* Convert output */ + igraph_vector_int_destroy(&c_colors); + IGRAPH_FINALLY_CLEAN(1); PROTECT(info=R_igraph_bliss_info_to_SEXP(&c_info)); if (c_info.group_size) { free(c_info.group_size); } r_result = info; @@ -6585,7 +6787,12 @@ SEXP R_igraph_automorphism_group(SEXP graph, SEXP colors, SEXP sh) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(colors)) { R_SEXP_to_vector_int_copy(colors, &c_colors); } + if (!Rf_isNull(colors)) { + R_SEXP_to_vector_int_copy(colors, &c_colors); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_colors, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_colors); if (0 != igraph_vector_ptr_init(&c_generators, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } @@ -6597,6 +6804,8 @@ SEXP R_igraph_automorphism_group(SEXP graph, SEXP colors, SEXP sh) { /* Convert output */ PROTECT(r_result=NEW_LIST(2)); PROTECT(r_names=NEW_CHARACTER(2)); + igraph_vector_int_destroy(&c_colors); + IGRAPH_FINALLY_CLEAN(1); PROTECT(generators=R_igraph_vectorlist_to_SEXP_p1(&c_generators)); R_igraph_vectorlist_destroy(&c_generators); IGRAPH_FINALLY_CLEAN(1); @@ -7240,7 +7449,12 @@ SEXP R_igraph_from_prufer(SEXP prufer) { SEXP r_result; /* Convert input */ - R_SEXP_to_vector_int_copy(prufer, &c_prufer); + if (!Rf_isNull(prufer)) { + R_SEXP_to_vector_int_copy(prufer, &c_prufer); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_prufer, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_prufer); /* Call igraph */ IGRAPH_R_CHECK(igraph_from_prufer(&c_graph, &c_prufer)); @@ -7249,6 +7463,8 @@ SEXP R_igraph_from_prufer(SEXP prufer) { PROTECT(graph=R_igraph_to_SEXP(&c_graph)); IGRAPH_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_prufer); + IGRAPH_FINALLY_CLEAN(1); r_result = graph; UNPROTECT(1); diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 43443b52d92..8e9e0210919 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -7221,7 +7221,12 @@ SEXP R_igraph_maximal_cliques(SEXP graph, SEXP psubset, SEXP result; R_SEXP_to_igraph(graph, &g); - if (!Rf_isNull(psubset)) { R_SEXP_to_vector_int_copy(psubset, &subset); } + if (!Rf_isNull(psubset)) { + R_SEXP_to_vector_int_copy(psubset, &subset); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&subset, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &subset); igraph_vector_ptr_init(&ptrvec,0); igraph_maximal_cliques_subset(&g, Rf_isNull(psubset) ? 0 : &subset, &ptrvec, /*no=*/ 0, /*file=*/ 0, @@ -7234,6 +7239,8 @@ SEXP R_igraph_maximal_cliques(SEXP graph, SEXP psubset, igraph_vector_destroy(vec); igraph_free(vec); } + igraph_vector_int_destroy(&subset); + IGRAPH_FINALLY_CLEAN(1); igraph_vector_ptr_destroy(&ptrvec); UNPROTECT(1); @@ -7254,7 +7261,12 @@ SEXP R_igraph_maximal_cliques_file(SEXP graph, SEXP psubset, SEXP file, #endif R_SEXP_to_igraph(graph, &g); - if (!Rf_isNull(psubset)) { R_SEXP_to_vector_int_copy(psubset, &subset); } + if (!Rf_isNull(psubset)) { + R_SEXP_to_vector_int_copy(psubset, &subset); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&subset, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &subset); #if HAVE_OPEN_MEMSTREAM == 1 stream=open_memstream(&bp, &size); #else @@ -7266,6 +7278,8 @@ SEXP R_igraph_maximal_cliques_file(SEXP graph, SEXP psubset, SEXP file, /*ptr=*/ 0, /*no=*/ 0, /*file=*/ stream, minsize, maxsize); fclose(stream); + igraph_vector_int_destroy(&subset); + IGRAPH_FINALLY_CLEAN(1); #if HAVE_OPEN_MEMSTREAM == 1 PROTECT(result=Rf_allocVector(RAWSXP, size)); memcpy(RAW(result), bp, sizeof(char)*size); @@ -7291,7 +7305,12 @@ SEXP R_igraph_maximal_cliques_count(SEXP graph, SEXP psubset, SEXP result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(psubset)) { R_SEXP_to_vector_int_copy(psubset, &subset); } + if (!Rf_isNull(psubset)) { + R_SEXP_to_vector_int_copy(psubset, &subset); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&subset, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &subset); c_min_size=INTEGER(min_size)[0]; c_max_size=INTEGER(max_size)[0]; /* Call igraph */ @@ -7299,6 +7318,8 @@ SEXP R_igraph_maximal_cliques_count(SEXP graph, SEXP psubset, /*ptr=*/ 0, &c_no, /*file=*/ 0, c_min_size, c_max_size); + igraph_vector_int_destroy(&subset); + IGRAPH_FINALLY_CLEAN(1); /* Convert output */ PROTECT(no=NEW_INTEGER(1)); INTEGER(no)[0]=c_no;