comparison R/rdc/demo/malloc.R @ 0:0cfcc391201f

initial from svn dyncall-1745
author Daniel Adler
date Thu, 19 Mar 2015 22:26:28 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:0cfcc391201f
1 # File: rdc/demo/malloc.R
2 # Description: sample demo to get malloc/free functions
3
4 if( .Platform$OS.type == "windows" ) {
5 .windir <- paste(Sys.getenv("windir")[[1]],"\\system32\\",sep="")
6 .libC <- paste(.windir,"msvcrt",sep="")
7 } else {
8 sysname <- Sys.info()[["sysname"]]
9 if (sysname == "Darwin")
10 {
11 .libC <- "/usr/lib/libc.dylib"
12 } else {
13 .libC <- "/lib/libc.so.6"
14 }
15 }
16
17 dyn.load(.libC)
18
19 bind <- function(name, signature)
20 {
21 address <- getNativeSymbolInfo(name)$address
22 assign(name, function(...) rdcCall(address,signature,...), parent.frame() )
23 }
24
25 bind("malloc","i)p")
26 bind("free","p)v")
27