similar to: protect/unprotect howto in C code

Displaying 20 results from an estimated 2000 matches similar to: "protect/unprotect howto in C code"

2009 Jan 08
1
Callbacks seems to get GCed.
Dear list, I am trying to implement a publish-subscribe mechanism in for an embedded R interpreter. But somehow my registered closures seem to get collected by the GC, even though I have protected them. I have reducted my code to the following sample. Sorry if it is a little verbose. The first couple of call of calls still work, but at some point one of the callbacks (callback1 in my
2019 Apr 05
2
Parsing code with newlines
Hello! This is my first post here. I came across the very same problem. It can be reproduced within modified tests/Embedding/RParseEval.c Actually this example has another issue, namely it doesn't wrap everything in R_ToplevelExec . This is a major show stopper for newcomers as that function is barely mentioned anywhere and longjmp into terminated setuploop function followed by R_suicide
2009 Aug 25
2
Clarifications please.
Hi I think I have asked these questions earlier, but I been able to find answers from the documentation (which I found poorly written in several places). Will someone be kind enough to give me answers and enlighten me? (as in explain with CODE?) I want to embed R in my application and use the fPortfolio package for carrying out risk management computations. Right now I'm reading the Rmetrics
2013 Oct 16
1
Parallel R expression evaluations
Hi all, I am using R-3.0.1 under Linux platform to embed R into my C++ code. I am facing an error while executing more than 1 R-expressions parallelly. I am executing round(X) and abs(X) parallelly on a set of 50 input rows which resulted in segmentation fault after getting the following errors. Error: unprotect_ptr: pointer not found Error: argument to 'findVar' is not an environment
2009 May 19
2
About " Error: C stack usage is too close to the limit"
Hi everyone! I meet one problem when embedding R in C code, when I run the the R code in one child thread , it always print error info: Error: C stack usage is too close to the limit I also try to set R_CStackLimit = (uintptr_t)-1 to disable the C stack check as the R-exts doc say, but it still does not work, the error info still exist. Besides it is interesting that if i
2009 Sep 16
2
I want to get a reference to this time series object
I'm trying to get a reference to this object in C SWX.RET[1:6,c("SBI,"SPI","SII")] While i am able to access and use a plain SWX.RET object, I'm getting confused on how to create an object with the array subscripts like above. Here is what I tried to do. It doesn't work because "[" is obviously not an operation or function on SWX.RET. So how do I
2009 Sep 29
3
How do I access class slots from C?
Hi I'm trying to implement something similar to the following R snippet using C. I seem to have hit the wall on accessing class slots using C. library(fPortfolio) lppData <- 100 * LPP2005.RET[, 1:6] ewSpec <- portfolioSpec() nAssets <- ncol(lppData) setWeights(ewSpec) <- rep(1/nAssets, times = nAssets) ewPortfolio <- feasiblePortfolio( data = lppData, spec = ewSpec,
2007 Apr 07
2
Rf_PrintValue problem with methods::show
Hi, I think this is a bug (even though I can't find documentation explicitly saying that it should work). Basically, Rf_PrintValue(obj) fails when 'obj' is an S4 object that should be printed using show() rather than print(). From the error message I'm guessing that the need to use show is detected correctly but then show is not found. "cbind2" in the code below is just
2009 Sep 03
1
Running an expression 1MN times using embedded R
Hello, I'm evaluating this expression expression({ for(x in 1:5){ .Call('rh_status','x') }}) a million times from a program with R embedded in it. I have attached reproducible code that crashes with Program received signal SIGSEGV, Segmentation fault. 0x00002b499ca40a6e in R_gc_internal (size_needed=0) at memory.c:1309 1309 FORWARD_NODE(R_PPStack[i]); Current language:
2011 Jan 26
2
Dealing with R list objects in C/C++
Hi, I'd like to construct an R list object in C++, fill it with relevant data, and pass it to an R function which will return a different list object back. I have browsed through all the R manuals, and examples under tests/Embedding, but can't figure out the correct way. Below is my code snippet: #include <Rinternals.h> // Rf_initEmbeddedR and other setups already performed
2007 Aug 16
0
call R function in c++ program
Hi all I don't know if my message are correct in this forums. I create a program in c++ who use statistical function. I want to execute this function in R (in particular for use packages ade4, lattice, bioconductor...) Until now, my program work for simple function ("plot", "rnorm"...) but I can't use library My class are : // in constructor int argc = 1;
2004 Apr 06
1
A question about embedded R
Hello everyone, I met a strange problem when I call R expression from C++, here is the details: I edited a function eval_R_command(); double eval_R_command(const char *funcName) { SEXP exp,e; ParseStatus status = PARSE_OK; int i,n; double val; PROTECT(exp=NEW_CHARACTER(1)); SET_STRING_ELT(exp, 0, COPY_TO_USER_STRING(funcName)); PROTECT(e = R_ParseVector(exp, 1,
2008 Sep 03
8
suggestion of new API function for embedded programming.
While doing some embedded programming and trying to figure out how to generate a hand coded SEXP equivalent of the line "t.test(x,conf.level=(1-p))$conf.int[2]" I had an idea for an addition to the embedded API. There are a number of hidden or static parse functions (R_ParseBuffer, R_Parse1Buffer, etc.) which take an IoBuffer* and returns a parsed tree. If one or more of these
2010 May 06
1
R on kdeedu-svn library problem
Hello, I am new to this list. ?I am trying to compile the current svn version of kdeedu on an amd64 linux machine ?which uses R and I get the following compiler output. ------------------------------------------- ?79%] Building CXX object cantor/src/backends/R/rserver/CMakeFiles/cantor_rserver.dir/rserver.o $SOURCES/kdeedu/cantor/src/backends/R/rserver/rserver.cpp: In member function
2012 Feb 01
3
Crash in R using embedded.
Hi, I'm new to R, and am trying to embed R into another application. I'm calling gev.fit() from the ismev package, and it is crashing somewhere inside it. gdb is not catching it, and valgrind is not showing any memory corruption issues. I suspect it's memory corruption, because it doesn't crash in exactly the same spot each time. I'm running R 2.12.2 on a 64 bit linux (Ubuntu
2009 Nov 28
1
PROTECT and OCaml GC.
Hello. In the writing of my OCaml-R binding, I'm sort of confused when it comes to the use of the PROTECT and UNPROTECT macros. Basically, I have C stub functions that are in charge of calling R for everything. Here's a simple example: > CAMLprim value r_findvar (value symbol) { > /* The findVar function is defined in envir.c. It looks up a symbol > in an environment.
2004 Oct 08
2
R-2.0.0 findVar and findFun question
Dear all, when working on a project with embedded R, I found out that R-2.0.0 causes a problem where older versions worked OK. Rf_findVar(...) causes the following error when used to find a generic function (such as print): fun = Rf_findVar(...); R_tryEval(fun, ...); Error in function (object, ...) : Invalid generic function in usemethod Alternatively, using Rf_findFun(...) seems OK in this
2010 Jan 14
1
how to call a function from C
Hi, In Rcpp, we now have a "Function" class to encapsulate functions (they cover all three kinds, but this may change). To call the function, what we do is generate a call with the function as the first node and then evaluate the call. SEXP stats = PROTECT( R_FindNamespace( mkString( "stats") ) ); SEXP rnorm = PROTECT( findVarInFrame( stats, install( "rnorm") ) )
2008 Jan 02
1
setting the seed in standalone code using Rlib
Hi, Is the below -- setSeed -- an okay way to set the seed in standalone applications making use of Rlib? It seems to work as expected. Is there a better way to do it? (I'm also looking at do_setseed but am unsure what to supply as op. findFun("set.seed", R_GlobalEnv)?) Thanks much. -- David Faden, dfaden at iastate.edu AIM: pitulx -- #include <assert.h> #include
2010 Sep 09
0
calling Rf_initEmbeddedR error
Hi all, I have a problem of Rf_initEmbeddedR function. I've tried with: try { int Argc1 = 1; char *Argv1[] = {"Rtest_1"}; int Argc2 = 1; char *Argv2[] = {"Rtest_2"}; // Init R(first) Rf_initEmbeddedR(Argc1, Argv1); // R package load SEXP e = R_NilValue; SEXP r = R_NilValue; PROTECT(e =