--- ray/src/util/rmatrix.c 2023/12/11 19:00:22 2.75 +++ ray/src/util/rmatrix.c 2023/12/21 23:58:05 2.77 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rmatrix.c,v 2.75 2023/12/11 19:00:22 greg Exp $"; +static const char RCSid[] = "$Id: rmatrix.c,v 2.77 2023/12/21 23:58:05 greg Exp $"; #endif /* * General matrix operations. @@ -393,8 +393,10 @@ rmx_load(const char *inspec, RMPref rmp) } /* else open it ourselves */ fp = fopen(inspec, "r"); } - if (!fp) + if (!fp) { + fprintf(stderr, "Cannot open for reading: %s\n", inspec); return(NULL); + } #ifdef getc_unlocked flockfile(fp); #endif @@ -685,12 +687,16 @@ rmx_transfer_data(RMATRIX *rdst, RMATRIX *rsrc, int do rsrc->info = NULL; rsrc->mapped = NULL; rsrc->mtx = NULL; return(1); } +#ifdef MAP_FILE /* just matrix data -- leave metadata */ if (rdst->mapped) - return(0); /* XXX can't handle this case */ - /* just matrix data -- leave metadata */ - if (rdst->mtx) free(rdst->mtx); + munmap(rdst->mapped, mapped_size(rdst)); + else +#endif + if (rdst->mtx) + free(rdst->mtx); + rdst->mapped = rsrc->mapped; rdst->mtx = rsrc->mtx; - rsrc->mtx = NULL; + rsrc->mapped = NULL; rsrc->mtx = NULL; return(1); }