The following change to init.c is only enabled if Guile was
authorMikael Djurfeldt <djurfeldt@nada.kth.se>
Tue, 14 Mar 2000 22:15:12 +0000 (22:15 +0000)
committerMikael Djurfeldt <djurfeldt@nada.kth.se>
Tue, 14 Mar 2000 22:15:12 +0000 (22:15 +0000)
configured with --enable-guile-debug.

* init.c (scm_i_getenv_int): New function.
(scm_boot_guile_1): Use the environment variables
GUILE_INIT_HEAP_SIZE, GUILE_INIT_HEAP_SIZE2 to select heap size if
they exist.  (This may be replaced by a Scheme level mechanism in
the future.)

libguile/init.c

index ef97770..dd66203 100644 (file)
@@ -356,6 +356,21 @@ scm_load_startup_files ()
     }
 }
 
+#ifdef GUILE_DEBUG
+/* Get an integer from an environment variable.  */
+static int
+scm_i_getenv_int (const char *var, int def)
+{
+  char *end, *val = getenv (var);
+  long res;
+  if (!val)
+    return def;
+  res = strtol (val, &end, 10);
+  if (end == val)
+    return def;
+  return res;
+}
+#endif /* GUILE_DEBUG */
 
 \f
 /* The main init code.  */
@@ -459,7 +474,12 @@ scm_boot_guile_1 (SCM_STACKITEM *base, struct main_func_closure *closure)
       scm_ports_prehistory ();
       scm_smob_prehistory ();
       scm_tables_prehistory ();
+#if GUILE_DEBUG
+      scm_init_storage (scm_i_getenv_int ("GUILE_INIT_HEAP_SIZE", 0),
+                       scm_i_getenv_int ("GUILE_INIT_HEAP_SIZE2", 0));
+#else
       scm_init_storage (0, 0);
+#endif
       scm_init_subr_table ();
       scm_init_root ();
 #ifdef USE_THREADS