diff --git a/la_traits.h b/la_traits.h index 802b4d3..12dcaf5 100644 --- a/la_traits.h +++ b/la_traits.h @@ -276,9 +276,10 @@ static inline void get(int fd, C &x, bool dimensions=0, bool transp=0) {if(sizeo static void multiget(size_t n,int fd, C *x, bool dimensions=0) { size_t total=0; + size_t system_limit = (1L<<30)/sizeof(C); //do not expect too much from the system and read at most 1GB at once ssize_t r; do{ - r=read(fd,x+total,(n-total)*sizeof(C)); + r=read(fd,x+total,(n-total > system_limit ? system_limit : n-total)*sizeof(C)); if(r<0 || r==0 && n!=0 ) {std::cout<<"read returned "< system_limit ? system_limit : n-total)*sizeof(C)); if(r<0 || r==0 && n!=0 ) {std::cout<<"write returned "<