Displaying 2 results from an estimated 2 matches for "r_simplepushbacktest".
2003 Dec 10
0
C++: SET_LENGTH() Over Many Iterations?
...ble memory.
Here's some simple test code I've been running:
<CPP Code>
#define PUSH_BACK_INTEGER(v, x) \
do {\
UNPROTECT_PTR(v);\
SET_LENGTH(v, GET_LENGTH(v) + 1);\
PROTECT(v);\
INTEGER_POINTER(v)[GET_LENGTH(v) - 1] = x;\
}\
while (false)
SEXP R_SimplePushBackTest(SEXP args)
{
SEXP arg1, arg2, int_vect;
PROTECT(arg1 = AS_INTEGER(CADR(args)));
int n_reps = INTEGER_POINTER(arg1)[0];
PROTECT(arg2 = AS_LOGICAL(CADDR(args)));
bool full_alloc = (LOGICAL_POINTER(arg2)[0] ? true : false);
if (full_alloc)
PROTECT(int_vect = NEW_INTEGE...
2003 Dec 12
3
C++: Appending Values onto an R-Vector.
Hi folks. I posted this question a few days ago, but maybe it got lost
because of the code I included with it. I'm having a problem using the
SET_LENGTH() macro in an R extension I'm writing in C++. In a function
within the extension I use SET_LENGTH() to resize R vectors so as to
allow the concatenation of single values onto the vectors -- it's a
"push back" function to