From 9d2e76e0a33419548d90ee1ba4df2edd47be71b8 Mon Sep 17 00:00:00 2001 From: Viktor Gal Date: Fri, 8 Dec 2017 11:59:42 +0100 Subject: [PATCH] change length vars to auto in R typemaps this way when switching to different index type there won't be any overflow problems --- src/interfaces/r/swig_typemaps.i | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/interfaces/r/swig_typemaps.i b/src/interfaces/r/swig_typemaps.i index baaf72fd6f4..bbd512884f4 100644 --- a/src/interfaces/r/swig_typemaps.i +++ b/src/interfaces/r/swig_typemaps.i @@ -67,11 +67,11 @@ TYPEMAP_IN_SGVECTOR(REALSXP, REAL, float64_t, "Double Precision") %typemap(out) shogun::SGVector { sg_type* vec = $1.vector; - int32_t len = $1.vlen; + auto len = $1.vlen; Rf_protect( $result = Rf_allocVector(r_type, len) ); - for (int32_t i=0; i { sg_type* matrix = $1.matrix; - int32_t num_feat = $1.num_rows; - int32_t num_vec = $1.num_cols; + auto num_feat = $1.num_rows; + auto num_vec = $1.num_cols; Rf_protect( $result = Rf_allocMatrix(r_type, num_feat, num_vec) ); - for (int32_t i=0; i { - int32_t max_len=0; - int32_t num_strings=0; + auto max_len=0; + auto num_strings=0; shogun::SGString* strs=NULL; if ($input == R_NilValue || TYPEOF($input) != STRSXP) @@ -173,11 +173,11 @@ TYPEMAP_OUT_SGMATRIX(INTSXP, INTEGER, uint16_t, int, "Word") ASSERT(num_strings>=1); strs=SG_MALLOC(shogun::SGString, num_strings); - for (int32_t i=0; i0) {