Skip to content

Commit

Permalink
R_NewEnv()
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Mar 6, 2025
1 parent 1894233 commit f06080e
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/rinterface_extra.c
Original file line number Diff line number Diff line change
Expand Up @@ -8659,16 +8659,12 @@ SEXP R_igraph_add_env(SEXP graph) {

// Get the base namespace
SEXP base_ns = PROTECT(R_FindNamespace(Rf_mkString("base"))); px++;
// Get the new.environment function
SEXP new_env_fun = PROTECT(Rf_findVarInFrame(base_ns, Rf_install("new.environment"))); px++;
// Get the emptyenv function
SEXP empty_env_fun = PROTECT(Rf_findVarInFrame(base_ns, Rf_install("emptyenv"))); px++;
// Call emptyenv()
SEXP empty_env = PROTECT(Rf_eval(Rf_lang1(empty_env_fun), R_GlobalEnv)); px++;
// Create environment with parent = emptyenv()
SEXP call = PROTECT(Rf_lang3(new_env_fun, Rf_install("parent"), empty_env)); px++;
// Evaluate the call
SEXP env = PROTECT(Rf_eval(call, R_GlobalEnv)); px++;
SEXP env = PROTECT(R_NewEnv(empty_env, 0, 0)); px++;

SET_VECTOR_ELT(result, igraph_t_idx_env, env);

Expand Down

0 comments on commit f06080e

Please sign in to comment.