aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan D2011-01-31 07:44:05 +0100
committerJan D2011-01-31 07:44:05 +0100
commit3370edca839da739185a7a0d91d22dfa23a22188 (patch)
tree507a2ed6c5a4a4bafe93411bf61ddd8d03b6284d
parent0832490d4431f3952c0c45de0d9c30ce0f8cc5c2 (diff)
downloademacs-3370edca839da739185a7a0d91d22dfa23a22188.tar.gz
emacs-3370edca839da739185a7a0d91d22dfa23a22188.zip
Use xmalloc instead of malloc.
* lwlib-Xm.c (make_destroyed_instance): * lwlib-utils.c (XtApplyToWidgets): * lwlib.c (safe_strdup, malloc_widget_value) (allocate_widget_info, allocate_widget_instance): Use xmalloc instead of malloc.
-rw-r--r--lwlib/ChangeLog8
-rw-r--r--lwlib/lwlib-Xm.c2
-rw-r--r--lwlib/lwlib-utils.c2
-rw-r--r--lwlib/lwlib.c10
4 files changed, 14 insertions, 8 deletions
diff --git a/lwlib/ChangeLog b/lwlib/ChangeLog
index 5015f2b8fa1..450ede33a50 100644
--- a/lwlib/ChangeLog
+++ b/lwlib/ChangeLog
@@ -1,3 +1,11 @@
12011-01-31 Jan Djärv <jan.h.d@swipnet.se>
2
3 * lwlib-Xm.c (make_destroyed_instance):
4 * lwlib-utils.c (XtApplyToWidgets):
5 * lwlib.c (safe_strdup, malloc_widget_value)
6 (allocate_widget_info, allocate_widget_instance): Use xmalloc
7 instead of malloc.
8
12011-01-25 Werner Meisner <weme24@gmx.net> 92011-01-25 Werner Meisner <weme24@gmx.net>
2 10
3 * lwlib-Xm.c (xm_update_menu): Avoid a NULL pointer dereference 11 * lwlib-Xm.c (xm_update_menu): Avoid a NULL pointer dereference
diff --git a/lwlib/lwlib-Xm.c b/lwlib/lwlib-Xm.c
index 14d1c03c4a3..059cf10d2bb 100644
--- a/lwlib/lwlib-Xm.c
+++ b/lwlib/lwlib-Xm.c
@@ -173,7 +173,7 @@ make_destroyed_instance (char* name,
173 Boolean pop_up_p) 173 Boolean pop_up_p)
174{ 174{
175 destroyed_instance* instance = 175 destroyed_instance* instance =
176 (destroyed_instance*)malloc (sizeof (destroyed_instance)); 176 (destroyed_instance*) xmalloc (sizeof (destroyed_instance));
177 instance->name = safe_strdup (name); 177 instance->name = safe_strdup (name);
178 instance->type = safe_strdup (type); 178 instance->type = safe_strdup (type);
179 instance->widget = widget; 179 instance->widget = widget;
diff --git a/lwlib/lwlib-utils.c b/lwlib/lwlib-utils.c
index 4e095d33fad..30f4f94f376 100644
--- a/lwlib/lwlib-utils.c
+++ b/lwlib/lwlib-utils.c
@@ -74,7 +74,7 @@ XtApplyToWidgets (Widget w, XtApplyToWidgetsProc proc, XtPointer arg)
74 the procedure might add/delete elements, which would lose badly. 74 the procedure might add/delete elements, which would lose badly.
75 */ 75 */
76 int nkids = cw->composite.num_children; 76 int nkids = cw->composite.num_children;
77 Widget *kids = (Widget *) malloc (sizeof (Widget) * nkids); 77 Widget *kids = (Widget *) xmalloc (sizeof (Widget) * nkids);
78 int i; 78 int i;
79 memcpy ((char *) kids, (char *) cw->composite.children, 79 memcpy ((char *) kids, (char *) cw->composite.children,
80 sizeof (Widget) * nkids); 80 sizeof (Widget) * nkids);
diff --git a/lwlib/lwlib.c b/lwlib/lwlib.c
index 677516a6b1c..e03196d7927 100644
--- a/lwlib/lwlib.c
+++ b/lwlib/lwlib.c
@@ -109,9 +109,7 @@ safe_strdup (const char *s)
109{ 109{
110 char *result; 110 char *result;
111 if (! s) return 0; 111 if (! s) return 0;
112 result = (char *) malloc (strlen (s) + 1); 112 result = (char *) xmalloc (strlen (s) + 1);
113 if (! result)
114 return 0;
115 strcpy (result, s); 113 strcpy (result, s);
116 return result; 114 return result;
117} 115}
@@ -157,7 +155,7 @@ malloc_widget_value (void)
157 } 155 }
158 else 156 else
159 { 157 {
160 wv = (widget_value *) malloc (sizeof (widget_value)); 158 wv = (widget_value *) xmalloc (sizeof (widget_value));
161 malloc_cpt++; 159 malloc_cpt++;
162 } 160 }
163 memset ((void*) wv, 0, sizeof (widget_value)); 161 memset ((void*) wv, 0, sizeof (widget_value));
@@ -257,7 +255,7 @@ allocate_widget_info (const char* type,
257 lw_callback post_activate_cb, 255 lw_callback post_activate_cb,
258 lw_callback highlight_cb) 256 lw_callback highlight_cb)
259{ 257{
260 widget_info* info = (widget_info*)malloc (sizeof (widget_info)); 258 widget_info* info = (widget_info*) xmalloc (sizeof (widget_info));
261 info->type = safe_strdup (type); 259 info->type = safe_strdup (type);
262 info->name = safe_strdup (name); 260 info->name = safe_strdup (name);
263 info->id = id; 261 info->id = id;
@@ -299,7 +297,7 @@ static widget_instance *
299allocate_widget_instance (widget_info* info, Widget parent, Boolean pop_up_p) 297allocate_widget_instance (widget_info* info, Widget parent, Boolean pop_up_p)
300{ 298{
301 widget_instance* instance = 299 widget_instance* instance =
302 (widget_instance*)malloc (sizeof (widget_instance)); 300 (widget_instance*) xmalloc (sizeof (widget_instance));
303 memset (instance, 0, sizeof *instance); 301 memset (instance, 0, sizeof *instance);
304 instance->parent = parent; 302 instance->parent = parent;
305 instance->pop_up_p = pop_up_p; 303 instance->pop_up_p = pop_up_p;