Skip to content

Commit

Permalink
chore: bool and FIXME (#755)
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr authored Apr 2, 2023
2 parents 5e7eba7 + ab81af2 commit af5a97f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/rinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@
*/

#include <stdbool.h>

#include "uuid/uuid.h"

#define R_IGRAPH_TYPE_VERSION "0.8.0"
#define R_IGRAPH_VERSION_VAR ".__igraph_version__."

SEXP R_igraph_add_env(SEXP graph);

void R_igraph_set_in_r_check(int set);
void R_igraph_set_in_r_check(bool set);
void R_igraph_error();
void R_igraph_warning();
void R_igraph_interrupt();
Expand Down
10 changes: 6 additions & 4 deletions src/rinterface_extra.c
Original file line number Diff line number Diff line change
Expand Up @@ -2383,9 +2383,9 @@ static int R_igraph_errors_count = 0;
static char R_igraph_warning_reason[4096];
static int R_igraph_warnings_count = 0;

static int R_igraph_in_r_check = 0;
static bool R_igraph_in_r_check = false;

void R_igraph_set_in_r_check(int set) {
void R_igraph_set_in_r_check(bool set) {
R_igraph_in_r_check = set;
}

Expand Down Expand Up @@ -2445,14 +2445,16 @@ void R_igraph_error_handler(const char *reason, const char *file,
* IGRAPH_FINALLY_FREE() because 'reason' might be allocated on the heap and
* IGRAPH_FINALLY_FREE() can then clean it up. */

if (R_igraph_errors_count == 0 || R_igraph_in_r_check == 0) {
if (R_igraph_errors_count == 0 || !R_igraph_in_r_check) {
snprintf(R_igraph_error_reason, sizeof(R_igraph_error_reason),
"At %s:%i : %s%s %s", file, line, reason,
maybe_add_punctuation(reason, ","),
igraph_strerror(igraph_errno));
R_igraph_error_reason[sizeof(R_igraph_error_reason) - 1] = 0;

if (R_igraph_in_r_check == 0) {
// FIXME: This is a hack, we should replace all memory allocations in the
// interface with RAII objects, and all longjmps with exceptions.
if (!R_igraph_in_r_check) {
IGRAPH_FINALLY_FREE();
R_igraph_error();
}
Expand Down

0 comments on commit af5a97f

Please sign in to comment.