summaryrefslogtreecommitdiff
path: root/lwlib/lwlib.c
diff options
context:
space:
mode:
authorFred Pierresteguy <F.Pierresteguy@frcl.bull.fr>1994-02-18 13:24:41 +0000
committerFred Pierresteguy <F.Pierresteguy@frcl.bull.fr>1994-02-18 13:24:41 +0000
commit0b96f00bb4b192ddb350ba1326c6b87bd67b5e93 (patch)
tree6ee4e561cef4f5d361eee393ea668ae938b6719e /lwlib/lwlib.c
parentb3eaa88e046027f4846074d6994cd8312bae3e69 (diff)
downloademacs-0b96f00bb4b192ddb350ba1326c6b87bd67b5e93.tar.gz
emacs-0b96f00bb4b192ddb350ba1326c6b87bd67b5e93.tar.bz2
emacs-0b96f00bb4b192ddb350ba1326c6b87bd67b5e93.zip
*** empty log message ***
Diffstat (limited to 'lwlib/lwlib.c')
-rw-r--r--lwlib/lwlib.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/lwlib/lwlib.c b/lwlib/lwlib.c
index e6af711e697..c2f2f05cba5 100644
--- a/lwlib/lwlib.c
+++ b/lwlib/lwlib.c
@@ -112,6 +112,8 @@ safe_free_str (s)
}
static widget_value *widget_value_free_list = 0;
+static int malloc_cpt = 0;
+static int malloc_cpt_id = 0;
widget_value *
malloc_widget_value ()
@@ -126,6 +128,7 @@ malloc_widget_value ()
else
{
wv = (widget_value *) malloc (sizeof (widget_value));
+ malloc_cpt++;
}
memset (wv, 0, sizeof (widget_value));
return wv;
@@ -140,8 +143,24 @@ free_widget_value (wv)
{
if (wv->free_list)
abort ();
- wv->free_list = widget_value_free_list;
- widget_value_free_list = wv;
+
+ if (malloc_cpt > 20)
+ {
+ /* When the number of already allocated cells is too big,
+ We free it. */
+ malloc_cpt_id++;
+ free (wv);
+ if (malloc_cpt_id > 20)
+ {
+ malloc_cpt_id = 0;
+ malloc_cpt = 0;
+ }
+ }
+ else
+ {
+ wv->free_list = widget_value_free_list;
+ widget_value_free_list = wv;
+ }
}
static void