"Jens Oehlschlägel"
2003-Nov-18 09:59 UTC
[R] How to return a big treelike list from .Call Interface (protect stack overflow)
I try to create a big treelike list structure using the RDefines/RInternal macros. The tree carries information at each node (attribute list) and at each leaf (vector). My understanding is that for each node I add to the binary tree I have to call PROTECT(newnode = NEW_LIST(2)); and cannot UNPROTECT before I return the whole tree. Same story for node attributes and leaf vectors. However, this way I easily reach the limit of the proteckt stack at 10000 (BTW this error is not catched). How can I increase the protect stack? Is there a better way to create such an R structure? Can one do C-side recursive list assignment MyList[[c(1,2,1,2,2,1)]] <<- NewSEXP without calling the R evaluator? Thanks for any help Best regards Jens Oehlschl?gel -- GMX Weihnachts-Special: Seychellen-Traumreise zu gewinnen! Rentier entlaufen. Finden Sie Rudolph! Als Belohnung winken tolle Preise. http://www.gmx.net/de/cgi/specialmail/
Peter Dalgaard
2003-Nov-18 10:39 UTC
[R] How to return a big treelike list from .Call Interface (protect stack overflow)
"Jens Oehlschl?gel" <joehl at gmx.de> writes:> I try to create a big treelike list structure using the RDefines/RInternal > macros. The tree carries information at each node (attribute list) and at each > leaf (vector). > My understanding is that for each node I add to the binary tree I have to > call > PROTECT(newnode = NEW_LIST(2)); > and cannot UNPROTECT before I return the whole tree. Same story for node > attributes and leaf vectors. However, this way I easily reach the limit of the > proteckt stack at 10000 (BTW this error is not catched). How can I increase > the protect stack? Is there a better way to create such an R structure? > Can one do C-side recursive list assignment MyList[[c(1,2,1,2,2,1)]] <<- > NewSEXP without calling the R evaluator?Nono, protection is recursive. You can UNPROTECT as soon as a structure becomes part of a PROTECT'ed structure, or even avoid protection at all if you assign immediately, e.g. SET_VECTOR_ELT(oldnode,0, newnode=NEW_LIST(2)) I believe the protect stack overflow situation has improved in 1.8.1. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Maybe Matching Threads
- larger than minimun MTU, forwarding via other node
- Duplicate declaration for files.
- [LLVMdev] [SafeCode] Unable to build the LLVM from trunk
- [LLVMdev] [cfe-dev] [SafeCode] Unable to build the LLVM from trunk
- [LLVMdev] Modifying DAG in TargetLowering::ReplaceNodeResults()