[Rd] Accessing Raw Mode Vectors from .C (PR#7853)
keithf at amnis.com
keithf at amnis.com
Wed May 11 20:43:27 CEST 2005
Full_Name: Keith Frost
Version: 2.0.0
OS: Linux i686 (RH 9)
Submission from: (NULL) (66.162.141.10)
If I create the C function:
void test_raw(unsigned char *raw, int *out)
{
int i;
for (i = 0; i <= 255; i++)
out[i] = raw[i];
}
and dyn.load the resulting library, then call
.C("test_raw", as.raw(255:0), integer(256), DUP=FALSE)[[2]];
the result is
[1] 24 0 0 224 160 116 31 8 0 158 93 8 160 184 107 8 0 1
[19] 0 0 111 34 41 0 255 254 253 252 251 250 249 248 247 246 245 244
[37] 243 242 241 240 239 238 237 236 235 234 233 232 231 230 229 228 227 226
[55] 225 224 223 222 221 220 219 218 217 216 215 214 213 212 211 210 209 208
... <10 deleted lines> ...
[253] 27 26 25 24
It appears that the C code gets a pointer which points 25 bytes before the
beginning of the raw vector data in memory. I know that this is not documented
to work, but it would be a *very* nice feature to have, and it looks like it
*almost* works.... Hence this bug report.
More information about the R-devel
mailing list