In a couple of places we calculate the maximum number of cases to keep
in memory based on the user-defined workspace.  Enable centralizing
the calculation through a new function.

Index: merge/src/data/settings.c
===================================================================
--- merge.orig/src/data/settings.c      2007-06-02 16:54:54.000000000 -0700
+++ merge/src/data/settings.c   2007-06-02 16:56:03.000000000 -0700
@@ -425,6 +425,16 @@
   return workspace;
 }
 
+/* Approximate maximum number of cases to allocate in-core, given
+   that each case contains VALUE_CNT values. */
+size_t
+get_workspace_cases (size_t value_cnt) 
+{
+  size_t case_size = sizeof (union value) * value_cnt + 4 * sizeof (void *);
+  size_t case_cnt = MAX (get_workspace () / case_size, 4);
+  return case_cnt;
+}
+
 /* Set approximate maximum amount of memory to use for cases, in
    bytes. */
 
Index: merge/src/data/settings.h
===================================================================
--- merge.orig/src/data/settings.h      2007-06-02 16:54:54.000000000 -0700
+++ merge/src/data/settings.h   2007-06-02 16:56:03.000000000 -0700
@@ -79,6 +79,7 @@
 void set_endcmd (char);
 
 size_t get_workspace (void);
+size_t get_workspace_cases (size_t value_cnt);
 void set_workspace (size_t);
 
 const struct fmt_spec *get_format (void);

--



_______________________________________________
pspp-dev mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/pspp-dev

Reply via email to