In a couple of places we calculate the maximum number of cases to keep
[pspp] / src / data / settings.c
index 3248324ea3a42640d95acf697a2813d21df123f6..5f769a5222083cb21a4a9e5731d23740e2680145 100644 (file)
@@ -425,6 +425,16 @@ get_workspace (void)
   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. */