pspp-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pspp-cvs] pspp/src/data scratch-reader.c ChangeLog


From: Ben Pfaff
Subject: [Pspp-cvs] pspp/src/data scratch-reader.c ChangeLog
Date: Sun, 07 May 2006 05:48:06 +0000

CVSROOT:        /cvsroot/pspp
Module name:    pspp
Branch:         
Changes by:     Ben Pfaff <address@hidden>      06/05/07 05:48:06

Modified files:
        src/data       : scratch-reader.c ChangeLog 

Log message:
        Fix memory leak in scratch reader.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/data/scratch-reader.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/data/ChangeLog.diff?tr1=1.44&tr2=1.45&r1=text&r2=text

Patches:
Index: pspp/src/data/ChangeLog
diff -u pspp/src/data/ChangeLog:1.44 pspp/src/data/ChangeLog:1.45
--- pspp/src/data/ChangeLog:1.44        Sun May  7 05:46:26 2006
+++ pspp/src/data/ChangeLog     Sun May  7 05:48:06 2006
@@ -1,3 +1,10 @@
+Sat May  6 22:46:47 2006  Ben Pfaff  <address@hidden>
+
+       * scratch-reader.c (scratch_reader_read_case): Copy into existing
+       case passed as argument instead of initializing the argument as a
+       case.  Fixes memory leak that showed up in
+       tests/command/aggregate.sh with scratch files.
+
 Sat May  6 22:45:55 2006  Ben Pfaff  <address@hidden>
 
        * procedure.c (proc_done): Destroy default_dict, to fix memory
Index: pspp/src/data/scratch-reader.c
diff -u pspp/src/data/scratch-reader.c:1.2 pspp/src/data/scratch-reader.c:1.3
--- pspp/src/data/scratch-reader.c:1.2  Wed Mar 15 03:29:10 2006
+++ pspp/src/data/scratch-reader.c      Sun May  7 05:48:06 2006
@@ -18,13 +18,18 @@
    02110-1301, USA. */
 
 #include <config.h>
+
 #include "scratch-reader.h"
+
 #include <stdlib.h>
+
 #include "casefile.h"
 #include "dictionary.h"
-#include <libpspp/message.h>
 #include "file-handle-def.h"
 #include "scratch-handle.h"
+#include <data/case.h>
+#include <libpspp/message.h>
+
 #include "xalloc.h"
 
 #include "gettext.h"
@@ -70,12 +75,22 @@
   return reader;
 }
 
-/* Reads a case from READER into C.
+/* Reads a case from READER and copies it into C.
    Returns true if successful, false on error or at end of file. */
 bool
 scratch_reader_read_case (struct scratch_reader *reader, struct ccase *c)
 {
-  return casereader_read (reader->casereader, c);
+  struct ccase tmp;
+  if (casereader_read (reader->casereader, &tmp)) 
+    {
+      case_copy (c, 0, &tmp, 0,
+                 casefile_get_value_cnt (
+                   casereader_get_casefile (reader->casereader)));
+      case_destroy (&tmp);
+      return true;
+    }
+  else
+    return false;
 }
 
 /* Returns true if an I/O error occurred on READER, false otherwise. */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]