X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fxemacs-chise.git.1;a=blobdiff_plain;f=src%2Fvm-limit.c;h=357e5c00a64359d4aba0ba75546fb8aaa6e179e7;hp=3294f124a302fb1f67a67a8bc284b69fd0f30c6f;hb=762383636a99307282c2d93d26c35c046ec24da1;hpb=6883ee56ec887c2c48abe5b06b5e66aa74031910 diff --git a/src/vm-limit.c b/src/vm-limit.c index 3294f12..357e5c0 100644 --- a/src/vm-limit.c +++ b/src/vm-limit.c @@ -45,7 +45,7 @@ static int warnlevel; /* Function to call to issue a warning; 0 means don't issue them. */ -static void (*warn_function) (CONST char *); +static void (*warn_function) (const char *); /* Get more memory space, complaining if we're near the end. */ @@ -57,6 +57,7 @@ check_memory_limits (void) POINTER cp; unsigned long five_percent; unsigned long data_size; + void (*save_warn_fun) (const char *); if (lim_data == 0) get_lim_data (); @@ -67,36 +68,43 @@ check_memory_limits (void) data_size = (char *) cp - (char *) data_space_start; if (warn_function) - switch (warnlevel) - { - case 0: - if (data_size > five_percent * 15) - { - warnlevel++; - (*warn_function) ("Warning: past 75% of memory limit"); - } - break; - - case 1: - if (data_size > five_percent * 17) - { - warnlevel++; - (*warn_function) ("Warning: past 85% of memory limit"); - } - break; - - case 2: - if (data_size > five_percent * 19) - { - warnlevel++; - (*warn_function) ("Warning: past 95% of memory limit"); - } - break; - - default: - (*warn_function) ("Warning: past acceptable memory limits"); - break; - } + { + /* temporarily reset the warn_function to 0 or we will get infinite + looping. */ + save_warn_fun = warn_function; + warn_function = 0; + switch (warnlevel) + { + case 0: + if (data_size > five_percent * 15) + { + warnlevel++; + (*warn_function) ("Warning: past 75% of memory limit"); + } + break; + + case 1: + if (data_size > five_percent * 17) + { + warnlevel++; + (*warn_function) ("Warning: past 85% of memory limit"); + } + break; + + case 2: + if (data_size > five_percent * 19) + { + warnlevel++; + (*warn_function) ("Warning: past 95% of memory limit"); + } + break; + + default: + (*warn_function) ("Warning: past acceptable memory limits"); + break; + } + warn_function = save_warn_fun; + } /* If we go down below 70% full, issue another 75% warning when we go up again. */ @@ -119,12 +127,12 @@ check_memory_limits (void) also declare where the end of pure storage is. */ void -memory_warnings (void *start, void (*warnfun) (CONST char *)) +memory_warnings (void *start, void (*warnfun) (const char *)) { extern void (* __after_morecore_hook) (void); /* From gmalloc.c */ if (start) - data_space_start = start; + data_space_start = (char*) start; else data_space_start = start_of_data ();