romainfrancois / altrepisode

Example altrep and C++ R :package:
Other
23 stars 3 forks source link

Incorrect Get_region methods #3

Open msannell opened 5 years ago

msannell commented 5 years ago

I think that you are mistaken about the semantics of the Get_region method. It should actually copy the region elements to the 'out' buffer. For example, the Get_region method for stdvec_double should be something like:

static R_xlen_t Get_region(SEXP vec, R_xlen_t start, R_xlen_t size, double* out){
  R_xlen_t len = Get(vec).size() - start;
  if (len>size)
  {
      len = size;
  }
  for (R_xlen_t i=0; i<len; ++i)
  {
      out[i] = Get(vec)[start+i];
  }
  return len;
}

You probably didn't notice this because Get_region is not called during operations like printing 'x' (the object returned by 'doubles()'), or 'str(x)' in R.

romainfrancois commented 5 years ago

Thanks, I'll have a look.