Browsing through the df_3dmatrix() to make sure I've covered everything,
I think I spotted a memory leak. Near the top of the routine is
if (df_binary) {
if (!fread_matrix(data_fp, &dmatrix, &nr, &nc, &rt, &ct))
int_error(NO_CARET, "Binary file read error: format unknown!");
/* fread_matrix() drains the file */
df_eof = 1;
} else {
which records the memory pointers to vectors rt and ct and matrix
dmatrix. Then near the bottom of the routine is
free_matrix(dmatrix, 0, nr - 1, 0);
if (rt)
free_vector(rt, 0);
if (ct)
free_vector(ct, 0);
But of course in between is all sorts of ways that the routine can error
out. Hence the memory leak. Try
splot "binary1" binary using 1
a bunch of times and watch memory increase.
The way to fix this naturally is to make dmatrix, rt annd ct static and
test for non-zero before allocating. If non-zero, free before calling
fread_matrix(). But again, whether it is worth fixing, I'm not sure.
(From my perspective, its obsolete.)
Dan
|