From: Ben Pfaff Date: Thu, 7 Jun 2007 05:15:58 +0000 (+0000) Subject: In a couple of places we calculate the maximum number of cases to keep X-Git-Tag: v0.6.0~450 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d8462bae6c13a723c63da24ed7db2549efd4cc1;p=pspp-builds.git 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. --- diff --git a/src/data/ChangeLog b/src/data/ChangeLog index 3e0ebf62..b783f78d 100644 --- a/src/data/ChangeLog +++ b/src/data/ChangeLog @@ -1,3 +1,11 @@ +2007-06-06 Ben Pfaff + + 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. + + * settings.c (get_workspace_cases): New function. + 2007-06-06 Ben Pfaff The casenumber type is defined in transformations.h, but case.h is diff --git a/src/data/settings.c b/src/data/settings.c index 3248324e..5f769a52 100644 --- a/src/data/settings.c +++ b/src/data/settings.c @@ -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. */ diff --git a/src/data/settings.h b/src/data/settings.h index 61e64e0f..b104e8a2 100644 --- a/src/data/settings.h +++ b/src/data/settings.h @@ -79,6 +79,7 @@ char get_endcmd (void); 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);