/// initialize inline static void Init_VCF_Buffer(SEXP File) { VCF_File = R_GetConnection(File); VCF_File->EOF_signalled = FALSE; VCF_Buffer.resize(VCF_BUFFER_SIZE + VCF_BUFFER_SIZE_PLUS); VCF_Buffer_EndPtr = VCF_Buffer_Ptr = &VCF_Buffer[0]; }
/* NOTE: retuns a *protected* object */ SEXP dybuf_alloc(unsigned long size, SEXP sConn) { SEXP s = PROTECT(allocVector(VECSXP, 2)); SEXP r = SET_VECTOR_ELT(s, 0, list1(allocVector(RAWSXP, size))); dybuf_info_t *d = (dybuf_info_t*) RAW(SET_VECTOR_ELT(s, 1, allocVector(RAWSXP, sizeof(dybuf_info_t)))); d->pos = 0; d->size = size; d->tail = r; d->data = (char*) RAW(CAR(r)); d->con = (sConn && inherits(sConn, "connection")) ? R_GetConnection(sConn) : 0; return s; }
Rconnection get_connection(SEXP con) { return R_GetConnection(con); }