diff options
| author | Fred Pierresteguy | 1994-02-18 13:24:41 +0000 |
|---|---|---|
| committer | Fred Pierresteguy | 1994-02-18 13:24:41 +0000 |
| commit | 0b96f00bb4b192ddb350ba1326c6b87bd67b5e93 (patch) | |
| tree | 6ee4e561cef4f5d361eee393ea668ae938b6719e | |
| parent | b3eaa88e046027f4846074d6994cd8312bae3e69 (diff) | |
| download | emacs-0b96f00bb4b192ddb350ba1326c6b87bd67b5e93.tar.gz emacs-0b96f00bb4b192ddb350ba1326c6b87bd67b5e93.zip | |
*** empty log message ***
| -rw-r--r-- | lwlib/lwlib-Xlw.c | 9 | ||||
| -rw-r--r-- | lwlib/lwlib.c | 23 |
2 files changed, 26 insertions, 6 deletions
diff --git a/lwlib/lwlib-Xlw.c b/lwlib/lwlib-Xlw.c index c48d6614b28..e07ee19c7bf 100644 --- a/lwlib/lwlib-Xlw.c +++ b/lwlib/lwlib-Xlw.c | |||
| @@ -71,13 +71,14 @@ pick_hook (w, client_data, call_data) | |||
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | /* creation functions */ | 73 | /* creation functions */ |
| 74 | |||
| 74 | static Widget | 75 | static Widget |
| 75 | xlw_create_menubar (instance) | 76 | xlw_create_menubar (instance) |
| 76 | widget_instance* instance; | 77 | widget_instance* instance; |
| 77 | { | 78 | { |
| 78 | Widget widget; | 79 | Widget widget; |
| 79 | 80 | ||
| 80 | widget_value *tem = (widget_value *) XtMalloc (sizeof (widget_value)); | 81 | widget_value *tem = malloc_widget_value (); |
| 81 | 82 | ||
| 82 | /* _XtCreate is freeing the object we passed, | 83 | /* _XtCreate is freeing the object we passed, |
| 83 | so make a copy that we free later. */ | 84 | so make a copy that we free later. */ |
| @@ -89,7 +90,7 @@ xlw_create_menubar (instance) | |||
| 89 | XtNmenu, tem, | 90 | XtNmenu, tem, |
| 90 | 0); | 91 | 0); |
| 91 | 92 | ||
| 92 | XtFree (tem); | 93 | free_widget_value (tem); |
| 93 | 94 | ||
| 94 | XtAddCallback (widget, XtNopen, pre_hook, (XtPointer)instance); | 95 | XtAddCallback (widget, XtNopen, pre_hook, (XtPointer)instance); |
| 95 | XtAddCallback (widget, XtNselect, pick_hook, (XtPointer)instance); | 96 | XtAddCallback (widget, XtNselect, pick_hook, (XtPointer)instance); |
| @@ -106,7 +107,7 @@ xlw_create_popup_menu (instance) | |||
| 106 | 107 | ||
| 107 | Widget widget; | 108 | Widget widget; |
| 108 | 109 | ||
| 109 | widget_value *tem = (widget_value *) XtMalloc (sizeof (widget_value)); | 110 | widget_value *tem = malloc_widget_value (); |
| 110 | 111 | ||
| 111 | /* _XtCreate is freeing the object we passed, | 112 | /* _XtCreate is freeing the object we passed, |
| 112 | so make a copy that we free later. */ | 113 | so make a copy that we free later. */ |
| @@ -119,7 +120,7 @@ xlw_create_popup_menu (instance) | |||
| 119 | XtNhorizontal, False, | 120 | XtNhorizontal, False, |
| 120 | 0); | 121 | 0); |
| 121 | 122 | ||
| 122 | XtFree (tem); | 123 | free_widget_value (tem); |
| 123 | 124 | ||
| 124 | XtAddCallback (widget, XtNselect, pick_hook, (XtPointer)instance); | 125 | XtAddCallback (widget, XtNselect, pick_hook, (XtPointer)instance); |
| 125 | 126 | ||
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) | |||
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | static widget_value *widget_value_free_list = 0; | 114 | static widget_value *widget_value_free_list = 0; |
| 115 | static int malloc_cpt = 0; | ||
| 116 | static int malloc_cpt_id = 0; | ||
| 115 | 117 | ||
| 116 | widget_value * | 118 | widget_value * |
| 117 | malloc_widget_value () | 119 | malloc_widget_value () |
| @@ -126,6 +128,7 @@ malloc_widget_value () | |||
| 126 | else | 128 | else |
| 127 | { | 129 | { |
| 128 | wv = (widget_value *) malloc (sizeof (widget_value)); | 130 | wv = (widget_value *) malloc (sizeof (widget_value)); |
| 131 | malloc_cpt++; | ||
| 129 | } | 132 | } |
| 130 | memset (wv, 0, sizeof (widget_value)); | 133 | memset (wv, 0, sizeof (widget_value)); |
| 131 | return wv; | 134 | return wv; |
| @@ -140,8 +143,24 @@ free_widget_value (wv) | |||
| 140 | { | 143 | { |
| 141 | if (wv->free_list) | 144 | if (wv->free_list) |
| 142 | abort (); | 145 | abort (); |
| 143 | wv->free_list = widget_value_free_list; | 146 | |
| 144 | widget_value_free_list = wv; | 147 | if (malloc_cpt > 20) |
| 148 | { | ||
| 149 | /* When the number of already allocated cells is too big, | ||
| 150 | We free it. */ | ||
| 151 | malloc_cpt_id++; | ||
| 152 | free (wv); | ||
| 153 | if (malloc_cpt_id > 20) | ||
| 154 | { | ||
| 155 | malloc_cpt_id = 0; | ||
| 156 | malloc_cpt = 0; | ||
| 157 | } | ||
| 158 | } | ||
| 159 | else | ||
| 160 | { | ||
| 161 | wv->free_list = widget_value_free_list; | ||
| 162 | widget_value_free_list = wv; | ||
| 163 | } | ||
| 145 | } | 164 | } |
| 146 | 165 | ||
| 147 | static void | 166 | static void |