diff options
| author | Dmitry Antipov | 2012-07-05 10:32:41 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-07-05 10:32:41 +0400 |
| commit | 23f86fce48e1cc8118f0ea5cce49d1acfd4364c4 (patch) | |
| tree | 837ae05f1ad4ad92936f804d580d95751779befe /src | |
| parent | 0497dc44b44f148425ff76c4cb7ef0d2ead9750b (diff) | |
| download | emacs-23f86fce48e1cc8118f0ea5cce49d1acfd4364c4.tar.gz emacs-23f86fce48e1cc8118f0ea5cce49d1acfd4364c4.zip | |
Cleanup xmalloc.
* admin/coccinelle/xzalloc.cocci: Semantic patch to convert
calls to xmalloc with following memset to xzalloc.
* src/lisp.h (xzalloc): New prototype. Omit needless casts.
* src/alloc.c (xzalloc): New function. Omit needless casts.
* src/charset.c: Omit needless casts. Convert all calls to
malloc with following memset to xzalloc.
* src/dispnew.c: Likewise.
* src/fringe.c: Likewise.
* src/image.c: Likewise.
* src/sound.c: Likewise.
* src/term.c: Likewise.
* src/w32fns.c: Likewise.
* src/w32font.c: Likewise.
* src/w32term.c: Likewise.
* src/xfaces.c: Likewise.
* src/xfns.c: Likewise.
* src/xterm.c: Likewise.
* src/atimer.c: Omit needless casts.
* src/buffer.c: Likewise.
* src/callproc.c: Likewise.
* src/ccl.c: Likewise.
* src/coding.c: Likewise.
* src/composite.c: Likewise.
* src/doc.c: Likewise.
* src/doprnt.c: Likewise.
* src/editfns.c: Likewise.
* src/emacs.c: Likewise.
* src/eval.c: Likewise.
* src/filelock.c: Likewise.
* src/fns.c: Likewise.
* src/gtkutil.c: Likewise.
* src/keyboard.c: Likewise.
* src/lisp.h: Likewise.
* src/lread.c: Likewise.
* src/minibuf.c: Likewise.
* src/msdos.c: Likewise.
* src/print.c: Likewise.
* src/process.c: Likewise.
* src/region-cache.c: Likewise.
* src/search.c: Likewise.
* src/sysdep.c: Likewise.
* src/termcap.c: Likewise.
* src/terminal.c: Likewise.
* src/tparam.c: Likewise.
* src/w16select.c: Likewise.
* src/w32.c: Likewise.
* src/w32reg.c: Likewise.
* src/w32select.c: Likewise.
* src/w32uniscribe.c: Likewise.
* src/widget.c: Likewise.
* src/xdisp.c: Likewise.
* src/xmenu.c: Likewise.
* src/xrdb.c: Likewise.
* src/xselect.c: Likewise.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 56 | ||||
| -rw-r--r-- | src/alloc.c | 22 | ||||
| -rw-r--r-- | src/atimer.c | 2 | ||||
| -rw-r--r-- | src/buffer.c | 8 | ||||
| -rw-r--r-- | src/callproc.c | 2 | ||||
| -rw-r--r-- | src/ccl.c | 2 | ||||
| -rw-r--r-- | src/charset.c | 3 | ||||
| -rw-r--r-- | src/coding.c | 2 | ||||
| -rw-r--r-- | src/composite.c | 2 | ||||
| -rw-r--r-- | src/dispnew.c | 23 | ||||
| -rw-r--r-- | src/doc.c | 2 | ||||
| -rw-r--r-- | src/doprnt.c | 2 | ||||
| -rw-r--r-- | src/editfns.c | 6 | ||||
| -rw-r--r-- | src/emacs.c | 2 | ||||
| -rw-r--r-- | src/eval.c | 2 | ||||
| -rw-r--r-- | src/filelock.c | 4 | ||||
| -rw-r--r-- | src/fns.c | 4 | ||||
| -rw-r--r-- | src/fringe.c | 13 | ||||
| -rw-r--r-- | src/gtkutil.c | 4 | ||||
| -rw-r--r-- | src/image.c | 55 | ||||
| -rw-r--r-- | src/keyboard.c | 7 | ||||
| -rw-r--r-- | src/lisp.h | 5 | ||||
| -rw-r--r-- | src/lread.c | 4 | ||||
| -rw-r--r-- | src/minibuf.c | 2 | ||||
| -rw-r--r-- | src/msdos.c | 12 | ||||
| -rw-r--r-- | src/print.c | 2 | ||||
| -rw-r--r-- | src/process.c | 8 | ||||
| -rw-r--r-- | src/region-cache.c | 8 | ||||
| -rw-r--r-- | src/search.c | 8 | ||||
| -rw-r--r-- | src/sound.c | 6 | ||||
| -rw-r--r-- | src/sysdep.c | 2 | ||||
| -rw-r--r-- | src/term.c | 14 | ||||
| -rw-r--r-- | src/termcap.c | 8 | ||||
| -rw-r--r-- | src/terminal.c | 6 | ||||
| -rw-r--r-- | src/tparam.c | 2 | ||||
| -rw-r--r-- | src/w16select.c | 4 | ||||
| -rw-r--r-- | src/w32.c | 6 | ||||
| -rw-r--r-- | src/w32fns.c | 18 | ||||
| -rw-r--r-- | src/w32font.c | 4 | ||||
| -rw-r--r-- | src/w32reg.c | 2 | ||||
| -rw-r--r-- | src/w32select.c | 2 | ||||
| -rw-r--r-- | src/w32term.c | 13 | ||||
| -rw-r--r-- | src/w32uniscribe.c | 2 | ||||
| -rw-r--r-- | src/widget.c | 4 | ||||
| -rw-r--r-- | src/xdisp.c | 2 | ||||
| -rw-r--r-- | src/xfaces.c | 13 | ||||
| -rw-r--r-- | src/xfns.c | 8 | ||||
| -rw-r--r-- | src/xmenu.c | 2 | ||||
| -rw-r--r-- | src/xrdb.c | 8 | ||||
| -rw-r--r-- | src/xselect.c | 25 | ||||
| -rw-r--r-- | src/xterm.c | 23 |
51 files changed, 231 insertions, 215 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index da769228190..704c0ce78d5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,59 @@ | |||
| 1 | 2012-07-05 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | Cleanup xmalloc. | ||
| 4 | * lisp.h (xzalloc): New prototype. Omit needless casts. | ||
| 5 | * alloc.c (xzalloc): New function. Omit needless casts. | ||
| 6 | * charset.c: Omit needless casts. Convert all calls to | ||
| 7 | xmalloc with following memset to xzalloc. | ||
| 8 | * dispnew.c: Likewise. | ||
| 9 | * fringe.c: Likewise. | ||
| 10 | * image.c: Likewise. | ||
| 11 | * sound.c: Likewise. | ||
| 12 | * term.c: Likewise. | ||
| 13 | * w32fns.c: Likewise. | ||
| 14 | * w32font.c: Likewise. | ||
| 15 | * w32term.c: Likewise. | ||
| 16 | * xfaces.c: Likewise. | ||
| 17 | * xfns.c: Likewise. | ||
| 18 | * xterm.c: Likewise. | ||
| 19 | * atimer.c: Omit needless casts. | ||
| 20 | * buffer.c: Likewise. | ||
| 21 | * callproc.c: Likewise. | ||
| 22 | * ccl.c: Likewise. | ||
| 23 | * coding.c: Likewise. | ||
| 24 | * composite.c: Likewise. | ||
| 25 | * doc.c: Likewise. | ||
| 26 | * doprnt.c: Likewise. | ||
| 27 | * editfns.c: Likewise. | ||
| 28 | * emacs.c: Likewise. | ||
| 29 | * eval.c: Likewise. | ||
| 30 | * filelock.c: Likewise. | ||
| 31 | * fns.c: Likewise. | ||
| 32 | * gtkutil.c: Likewise. | ||
| 33 | * keyboard.c: Likewise. | ||
| 34 | * lisp.h: Likewise. | ||
| 35 | * lread.c: Likewise. | ||
| 36 | * minibuf.c: Likewise. | ||
| 37 | * msdos.c: Likewise. | ||
| 38 | * print.c: Likewise. | ||
| 39 | * process.c: Likewise. | ||
| 40 | * region-cache.c: Likewise. | ||
| 41 | * search.c: Likewise. | ||
| 42 | * sysdep.c: Likewise. | ||
| 43 | * termcap.c: Likewise. | ||
| 44 | * terminal.c: Likewise. | ||
| 45 | * tparam.c: Likewise. | ||
| 46 | * w16select.c: Likewise. | ||
| 47 | * w32.c: Likewise. | ||
| 48 | * w32reg.c: Likewise. | ||
| 49 | * w32select.c: Likewise. | ||
| 50 | * w32uniscribe.c: Likewise. | ||
| 51 | * widget.c: Likewise. | ||
| 52 | * xdisp.c: Likewise. | ||
| 53 | * xmenu.c: Likewise. | ||
| 54 | * xrdb.c: Likewise. | ||
| 55 | * xselect.c: Likewise. | ||
| 56 | |||
| 1 | 2012-07-05 Paul Eggert <eggert@cs.ucla.edu> | 57 | 2012-07-05 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 58 | ||
| 3 | * fileio.c (time_error_value): Check the right error number. | 59 | * fileio.c (time_error_value): Check the right error number. |
diff --git a/src/alloc.c b/src/alloc.c index ed5d6b5099f..6ef0782ca1b 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -735,6 +735,22 @@ xmalloc (size_t size) | |||
| 735 | return val; | 735 | return val; |
| 736 | } | 736 | } |
| 737 | 737 | ||
| 738 | /* Like the above, but zeroes out the memory just allocated. */ | ||
| 739 | |||
| 740 | void * | ||
| 741 | xzalloc (size_t size) | ||
| 742 | { | ||
| 743 | void *val; | ||
| 744 | |||
| 745 | MALLOC_BLOCK_INPUT; | ||
| 746 | val = malloc (size); | ||
| 747 | MALLOC_UNBLOCK_INPUT; | ||
| 748 | |||
| 749 | if (!val && size) | ||
| 750 | memory_full (size); | ||
| 751 | memset (val, 0, size); | ||
| 752 | return val; | ||
| 753 | } | ||
| 738 | 754 | ||
| 739 | /* Like realloc but check for no memory and block interrupt input.. */ | 755 | /* Like realloc but check for no memory and block interrupt input.. */ |
| 740 | 756 | ||
| @@ -867,7 +883,7 @@ char * | |||
| 867 | xstrdup (const char *s) | 883 | xstrdup (const char *s) |
| 868 | { | 884 | { |
| 869 | size_t len = strlen (s) + 1; | 885 | size_t len = strlen (s) + 1; |
| 870 | char *p = (char *) xmalloc (len); | 886 | char *p = xmalloc (len); |
| 871 | memcpy (p, s, len); | 887 | memcpy (p, s, len); |
| 872 | return p; | 888 | return p; |
| 873 | } | 889 | } |
| @@ -3881,7 +3897,7 @@ mem_insert (void *start, void *end, enum mem_type type) | |||
| 3881 | if (x == NULL) | 3897 | if (x == NULL) |
| 3882 | abort (); | 3898 | abort (); |
| 3883 | #else | 3899 | #else |
| 3884 | x = (struct mem_node *) xmalloc (sizeof *x); | 3900 | x = xmalloc (sizeof *x); |
| 3885 | #endif | 3901 | #endif |
| 3886 | x->start = start; | 3902 | x->start = start; |
| 3887 | x->end = end; | 3903 | x->end = end; |
| @@ -5047,7 +5063,7 @@ pure_alloc (size_t size, int type) | |||
| 5047 | /* Don't allocate a large amount here, | 5063 | /* Don't allocate a large amount here, |
| 5048 | because it might get mmap'd and then its address | 5064 | because it might get mmap'd and then its address |
| 5049 | might not be usable. */ | 5065 | might not be usable. */ |
| 5050 | purebeg = (char *) xmalloc (10000); | 5066 | purebeg = xmalloc (10000); |
| 5051 | pure_size = 10000; | 5067 | pure_size = 10000; |
| 5052 | pure_bytes_used_before_overflow += pure_bytes_used - size; | 5068 | pure_bytes_used_before_overflow += pure_bytes_used - size; |
| 5053 | pure_bytes_used = 0; | 5069 | pure_bytes_used = 0; |
diff --git a/src/atimer.c b/src/atimer.c index e72bc305753..39ac3e826bb 100644 --- a/src/atimer.c +++ b/src/atimer.c | |||
| @@ -107,7 +107,7 @@ start_atimer (enum atimer_type type, EMACS_TIME timestamp, atimer_callback fn, | |||
| 107 | free_atimers = t->next; | 107 | free_atimers = t->next; |
| 108 | } | 108 | } |
| 109 | else | 109 | else |
| 110 | t = (struct atimer *) xmalloc (sizeof *t); | 110 | t = xmalloc (sizeof *t); |
| 111 | 111 | ||
| 112 | /* Fill the atimer structure. */ | 112 | /* Fill the atimer structure. */ |
| 113 | memset (t, 0, sizeof *t); | 113 | memset (t, 0, sizeof *t); |
diff --git a/src/buffer.c b/src/buffer.c index e1652e9e105..e1c33f4c711 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -3893,7 +3893,7 @@ DEFUN ("overlays-at", Foverlays_at, Soverlays_at, 1, 1, 0, | |||
| 3893 | 3893 | ||
| 3894 | len = 10; | 3894 | len = 10; |
| 3895 | /* We can't use alloca here because overlays_at can call xrealloc. */ | 3895 | /* We can't use alloca here because overlays_at can call xrealloc. */ |
| 3896 | overlay_vec = (Lisp_Object *) xmalloc (len * sizeof (Lisp_Object)); | 3896 | overlay_vec = xmalloc (len * sizeof (Lisp_Object)); |
| 3897 | 3897 | ||
| 3898 | /* Put all the overlays we want in a vector in overlay_vec. | 3898 | /* Put all the overlays we want in a vector in overlay_vec. |
| 3899 | Store the length in len. */ | 3899 | Store the length in len. */ |
| @@ -3924,7 +3924,7 @@ end of the buffer. */) | |||
| 3924 | CHECK_NUMBER_COERCE_MARKER (end); | 3924 | CHECK_NUMBER_COERCE_MARKER (end); |
| 3925 | 3925 | ||
| 3926 | len = 10; | 3926 | len = 10; |
| 3927 | overlay_vec = (Lisp_Object *) xmalloc (len * sizeof (Lisp_Object)); | 3927 | overlay_vec = xmalloc (len * sizeof (Lisp_Object)); |
| 3928 | 3928 | ||
| 3929 | /* Put all the overlays we want in a vector in overlay_vec. | 3929 | /* Put all the overlays we want in a vector in overlay_vec. |
| 3930 | Store the length in len. */ | 3930 | Store the length in len. */ |
| @@ -3952,7 +3952,7 @@ the value is (point-max). */) | |||
| 3952 | CHECK_NUMBER_COERCE_MARKER (pos); | 3952 | CHECK_NUMBER_COERCE_MARKER (pos); |
| 3953 | 3953 | ||
| 3954 | len = 10; | 3954 | len = 10; |
| 3955 | overlay_vec = (Lisp_Object *) xmalloc (len * sizeof (Lisp_Object)); | 3955 | overlay_vec = xmalloc (len * sizeof (Lisp_Object)); |
| 3956 | 3956 | ||
| 3957 | /* Put all the overlays we want in a vector in overlay_vec. | 3957 | /* Put all the overlays we want in a vector in overlay_vec. |
| 3958 | Store the length in len. | 3958 | Store the length in len. |
| @@ -3996,7 +3996,7 @@ the value is (point-min). */) | |||
| 3996 | return pos; | 3996 | return pos; |
| 3997 | 3997 | ||
| 3998 | len = 10; | 3998 | len = 10; |
| 3999 | overlay_vec = (Lisp_Object *) xmalloc (len * sizeof (Lisp_Object)); | 3999 | overlay_vec = xmalloc (len * sizeof (Lisp_Object)); |
| 4000 | 4000 | ||
| 4001 | /* Put all the overlays we want in a vector in overlay_vec. | 4001 | /* Put all the overlays we want in a vector in overlay_vec. |
| 4002 | Store the length in len. | 4002 | Store the length in len. |
diff --git a/src/callproc.c b/src/callproc.c index 70780996f27..0418e4e8cd5 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -1172,7 +1172,7 @@ child_setup (int in, int out, int err, register char **new_argv, int set_pgrp, L | |||
| 1172 | /* MSDOS must have all environment variables malloc'ed, because | 1172 | /* MSDOS must have all environment variables malloc'ed, because |
| 1173 | low-level libc functions that launch subsidiary processes rely | 1173 | low-level libc functions that launch subsidiary processes rely |
| 1174 | on that. */ | 1174 | on that. */ |
| 1175 | pwd_var = (char *) xmalloc (i + 6); | 1175 | pwd_var = xmalloc (i + 6); |
| 1176 | #else | 1176 | #else |
| 1177 | pwd_var = (char *) alloca (i + 6); | 1177 | pwd_var = (char *) alloca (i + 6); |
| 1178 | #endif | 1178 | #endif |
| @@ -2098,7 +2098,7 @@ usage: (ccl-execute-on-string CCL-PROGRAM STATUS STRING &optional CONTINUE UNIBY | |||
| 2098 | outbufsize = (ccl.buf_magnification | 2098 | outbufsize = (ccl.buf_magnification |
| 2099 | ? str_bytes * ccl.buf_magnification + 256 | 2099 | ? str_bytes * ccl.buf_magnification + 256 |
| 2100 | : str_bytes + 256); | 2100 | : str_bytes + 256); |
| 2101 | outp = outbuf = (unsigned char *) xmalloc (outbufsize); | 2101 | outp = outbuf = xmalloc (outbufsize); |
| 2102 | 2102 | ||
| 2103 | consumed_chars = consumed_bytes = 0; | 2103 | consumed_chars = consumed_bytes = 0; |
| 2104 | produced_chars = 0; | 2104 | produced_chars = 0; |
diff --git a/src/charset.c b/src/charset.c index d92c909dc0c..a0ed9673e98 100644 --- a/src/charset.c +++ b/src/charset.c | |||
| @@ -912,8 +912,7 @@ usage: (define-charset-internal ...) */) | |||
| 912 | 912 | ||
| 913 | if (! charset.code_linear_p) | 913 | if (! charset.code_linear_p) |
| 914 | { | 914 | { |
| 915 | charset.code_space_mask = (unsigned char *) xmalloc (256); | 915 | charset.code_space_mask = xzalloc (256); |
| 916 | memset (charset.code_space_mask, 0, 256); | ||
| 917 | for (i = 0; i < 4; i++) | 916 | for (i = 0; i < 4; i++) |
| 918 | for (j = charset.code_space[i * 4]; j <= charset.code_space[i * 4 + 1]; | 917 | for (j = charset.code_space[i * 4]; j <= charset.code_space[i * 4 + 1]; |
| 919 | j++) | 918 | j++) |
diff --git a/src/coding.c b/src/coding.c index b0359b89cb5..891fea09abf 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -8006,7 +8006,7 @@ encode_coding_object (struct coding_system *coding, | |||
| 8006 | { | 8006 | { |
| 8007 | ptrdiff_t dst_bytes = max (1, coding->src_chars); | 8007 | ptrdiff_t dst_bytes = max (1, coding->src_chars); |
| 8008 | coding->dst_object = Qnil; | 8008 | coding->dst_object = Qnil; |
| 8009 | coding->destination = (unsigned char *) xmalloc (dst_bytes); | 8009 | coding->destination = xmalloc (dst_bytes); |
| 8010 | coding->dst_bytes = dst_bytes; | 8010 | coding->dst_bytes = dst_bytes; |
| 8011 | coding->dst_multibyte = 0; | 8011 | coding->dst_multibyte = 0; |
| 8012 | } | 8012 | } |
diff --git a/src/composite.c b/src/composite.c index 6c24bc8bc6f..464b55202d7 100644 --- a/src/composite.c +++ b/src/composite.c | |||
| @@ -326,7 +326,7 @@ get_composition_id (ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t nchars, | |||
| 326 | memory_full (SIZE_MAX); | 326 | memory_full (SIZE_MAX); |
| 327 | 327 | ||
| 328 | /* Register the composition in composition_table. */ | 328 | /* Register the composition in composition_table. */ |
| 329 | cmp = (struct composition *) xmalloc (sizeof (struct composition)); | 329 | cmp = xmalloc (sizeof (struct composition)); |
| 330 | 330 | ||
| 331 | cmp->method = method; | 331 | cmp->method = method; |
| 332 | cmp->hash_index = hash_index; | 332 | cmp->hash_index = hash_index; |
diff --git a/src/dispnew.c b/src/dispnew.c index 767f1c8112b..17bd2e828fa 100644 --- a/src/dispnew.c +++ b/src/dispnew.c | |||
| @@ -344,11 +344,7 @@ __executable_start (void) | |||
| 344 | static struct glyph_matrix * | 344 | static struct glyph_matrix * |
| 345 | new_glyph_matrix (struct glyph_pool *pool) | 345 | new_glyph_matrix (struct glyph_pool *pool) |
| 346 | { | 346 | { |
| 347 | struct glyph_matrix *result; | 347 | struct glyph_matrix *result = xzalloc (sizeof *result); |
| 348 | |||
| 349 | /* Allocate and clear. */ | ||
| 350 | result = (struct glyph_matrix *) xmalloc (sizeof *result); | ||
| 351 | memset (result, 0, sizeof *result); | ||
| 352 | 348 | ||
| 353 | /* Increment number of allocated matrices. This count is used | 349 | /* Increment number of allocated matrices. This count is used |
| 354 | to detect memory leaks. */ | 350 | to detect memory leaks. */ |
| @@ -1367,11 +1363,7 @@ row_equal_p (struct glyph_row *a, struct glyph_row *b, int mouse_face_p) | |||
| 1367 | static struct glyph_pool * | 1363 | static struct glyph_pool * |
| 1368 | new_glyph_pool (void) | 1364 | new_glyph_pool (void) |
| 1369 | { | 1365 | { |
| 1370 | struct glyph_pool *result; | 1366 | struct glyph_pool *result = xzalloc (sizeof *result); |
| 1371 | |||
| 1372 | /* Allocate a new glyph_pool and clear it. */ | ||
| 1373 | result = (struct glyph_pool *) xmalloc (sizeof *result); | ||
| 1374 | memset (result, 0, sizeof *result); | ||
| 1375 | 1367 | ||
| 1376 | /* For memory leak and double deletion checking. */ | 1368 | /* For memory leak and double deletion checking. */ |
| 1377 | ++glyph_pool_count; | 1369 | ++glyph_pool_count; |
| @@ -2033,19 +2025,16 @@ save_current_matrix (struct frame *f) | |||
| 2033 | int i; | 2025 | int i; |
| 2034 | struct glyph_matrix *saved; | 2026 | struct glyph_matrix *saved; |
| 2035 | 2027 | ||
| 2036 | saved = (struct glyph_matrix *) xmalloc (sizeof *saved); | 2028 | saved = xzalloc (sizeof *saved); |
| 2037 | memset (saved, 0, sizeof *saved); | ||
| 2038 | saved->nrows = f->current_matrix->nrows; | 2029 | saved->nrows = f->current_matrix->nrows; |
| 2039 | saved->rows = (struct glyph_row *) xmalloc (saved->nrows | 2030 | saved->rows = xzalloc (saved->nrows * sizeof *saved->rows); |
| 2040 | * sizeof *saved->rows); | ||
| 2041 | memset (saved->rows, 0, saved->nrows * sizeof *saved->rows); | ||
| 2042 | 2031 | ||
| 2043 | for (i = 0; i < saved->nrows; ++i) | 2032 | for (i = 0; i < saved->nrows; ++i) |
| 2044 | { | 2033 | { |
| 2045 | struct glyph_row *from = f->current_matrix->rows + i; | 2034 | struct glyph_row *from = f->current_matrix->rows + i; |
| 2046 | struct glyph_row *to = saved->rows + i; | 2035 | struct glyph_row *to = saved->rows + i; |
| 2047 | ptrdiff_t nbytes = from->used[TEXT_AREA] * sizeof (struct glyph); | 2036 | ptrdiff_t nbytes = from->used[TEXT_AREA] * sizeof (struct glyph); |
| 2048 | to->glyphs[TEXT_AREA] = (struct glyph *) xmalloc (nbytes); | 2037 | to->glyphs[TEXT_AREA] = xmalloc (nbytes); |
| 2049 | memcpy (to->glyphs[TEXT_AREA], from->glyphs[TEXT_AREA], nbytes); | 2038 | memcpy (to->glyphs[TEXT_AREA], from->glyphs[TEXT_AREA], nbytes); |
| 2050 | to->used[TEXT_AREA] = from->used[TEXT_AREA]; | 2039 | to->used[TEXT_AREA] = from->used[TEXT_AREA]; |
| 2051 | } | 2040 | } |
| @@ -2263,7 +2252,7 @@ adjust_frame_message_buffer (struct frame *f) | |||
| 2263 | FRAME_MESSAGE_BUF (f) = new_buffer; | 2252 | FRAME_MESSAGE_BUF (f) = new_buffer; |
| 2264 | } | 2253 | } |
| 2265 | else | 2254 | else |
| 2266 | FRAME_MESSAGE_BUF (f) = (char *) xmalloc (size); | 2255 | FRAME_MESSAGE_BUF (f) = xmalloc (size); |
| 2267 | } | 2256 | } |
| 2268 | 2257 | ||
| 2269 | 2258 | ||
| @@ -757,7 +757,7 @@ Otherwise, return a new string, without any text properties. */) | |||
| 757 | keymap = Voverriding_local_map; | 757 | keymap = Voverriding_local_map; |
| 758 | 758 | ||
| 759 | bsize = SBYTES (string); | 759 | bsize = SBYTES (string); |
| 760 | bufp = buf = (char *) xmalloc (bsize); | 760 | bufp = buf = xmalloc (bsize); |
| 761 | 761 | ||
| 762 | strp = SDATA (string); | 762 | strp = SDATA (string); |
| 763 | while (strp < SDATA (string) + SBYTES (string)) | 763 | while (strp < SDATA (string) + SBYTES (string)) |
diff --git a/src/doprnt.c b/src/doprnt.c index 2aa236d8bbf..44dc641d5dd 100644 --- a/src/doprnt.c +++ b/src/doprnt.c | |||
| @@ -257,7 +257,7 @@ doprnt (char *buffer, ptrdiff_t bufsize, const char *format, | |||
| 257 | { | 257 | { |
| 258 | if (big_buffer) | 258 | if (big_buffer) |
| 259 | xfree (big_buffer); | 259 | xfree (big_buffer); |
| 260 | big_buffer = (char *) xmalloc (size_bound); | 260 | big_buffer = xmalloc (size_bound); |
| 261 | sprintf_buffer = big_buffer; | 261 | sprintf_buffer = big_buffer; |
| 262 | size_allocated = size_bound; | 262 | size_allocated = size_bound; |
| 263 | } | 263 | } |
diff --git a/src/editfns.c b/src/editfns.c index 8812ed9e555..741a97f7113 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -2157,8 +2157,8 @@ set_time_zone_rule (const char *tzstring) | |||
| 2157 | for (from = environ; *from; from++) | 2157 | for (from = environ; *from; from++) |
| 2158 | continue; | 2158 | continue; |
| 2159 | envptrs = from - environ + 2; | 2159 | envptrs = from - environ + 2; |
| 2160 | newenv = to = (char **) xmalloc (envptrs * sizeof (char *) | 2160 | newenv = to = xmalloc (envptrs * sizeof (char *) |
| 2161 | + (tzstring ? strlen (tzstring) + 4 : 0)); | 2161 | + (tzstring ? strlen (tzstring) + 4 : 0)); |
| 2162 | 2162 | ||
| 2163 | /* Add TZSTRING to the end of environ, as a value for TZ. */ | 2163 | /* Add TZSTRING to the end of environ, as a value for TZ. */ |
| 2164 | if (tzstring) | 2164 | if (tzstring) |
| @@ -3477,7 +3477,7 @@ usage: (message-box FORMAT-STRING &rest ARGS) */) | |||
| 3477 | /* Copy the data so that it won't move when we GC. */ | 3477 | /* Copy the data so that it won't move when we GC. */ |
| 3478 | if (! message_text) | 3478 | if (! message_text) |
| 3479 | { | 3479 | { |
| 3480 | message_text = (char *)xmalloc (80); | 3480 | message_text = xmalloc (80); |
| 3481 | message_length = 80; | 3481 | message_length = 80; |
| 3482 | } | 3482 | } |
| 3483 | if (SBYTES (val) > message_length) | 3483 | if (SBYTES (val) > message_length) |
diff --git a/src/emacs.c b/src/emacs.c index 861c19ee0b5..6a7e9299b36 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -1820,7 +1820,7 @@ static const struct standard_args standard_args[] = | |||
| 1820 | static void | 1820 | static void |
| 1821 | sort_args (int argc, char **argv) | 1821 | sort_args (int argc, char **argv) |
| 1822 | { | 1822 | { |
| 1823 | char **new = (char **) xmalloc (sizeof (char *) * argc); | 1823 | char **new = xmalloc (sizeof (char *) * argc); |
| 1824 | /* For each element of argv, | 1824 | /* For each element of argv, |
| 1825 | the corresponding element of options is: | 1825 | the corresponding element of options is: |
| 1826 | 0 for an option that takes no arguments, | 1826 | 0 for an option that takes no arguments, |
diff --git a/src/eval.c b/src/eval.c index 906adb8bf8e..d35b71530ac 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -138,7 +138,7 @@ void | |||
| 138 | init_eval_once (void) | 138 | init_eval_once (void) |
| 139 | { | 139 | { |
| 140 | enum { size = 50 }; | 140 | enum { size = 50 }; |
| 141 | specpdl = (struct specbinding *) xmalloc (size * sizeof (struct specbinding)); | 141 | specpdl = xmalloc (size * sizeof (struct specbinding)); |
| 142 | specpdl_size = size; | 142 | specpdl_size = size; |
| 143 | specpdl_ptr = specpdl; | 143 | specpdl_ptr = specpdl; |
| 144 | /* Don't forget to update docs (lispref node "Local Variables"). */ | 144 | /* Don't forget to update docs (lispref node "Local Variables"). */ |
diff --git a/src/filelock.c b/src/filelock.c index a0ac154a0d2..1497529c6e0 100644 --- a/src/filelock.c +++ b/src/filelock.c | |||
| @@ -422,7 +422,7 @@ current_lock_owner (lock_info_type *owner, char *lfname) | |||
| 422 | return -1; | 422 | return -1; |
| 423 | } | 423 | } |
| 424 | len = at - lfinfo; | 424 | len = at - lfinfo; |
| 425 | owner->user = (char *) xmalloc (len + 1); | 425 | owner->user = xmalloc (len + 1); |
| 426 | memcpy (owner->user, lfinfo, len); | 426 | memcpy (owner->user, lfinfo, len); |
| 427 | owner->user[len] = 0; | 427 | owner->user[len] = 0; |
| 428 | 428 | ||
| @@ -449,7 +449,7 @@ current_lock_owner (lock_info_type *owner, char *lfname) | |||
| 449 | 449 | ||
| 450 | /* The host is everything in between. */ | 450 | /* The host is everything in between. */ |
| 451 | len = dot - at - 1; | 451 | len = dot - at - 1; |
| 452 | owner->host = (char *) xmalloc (len + 1); | 452 | owner->host = xmalloc (len + 1); |
| 453 | memcpy (owner->host, at + 1, len); | 453 | memcpy (owner->host, at + 1, len); |
| 454 | owner->host[len] = 0; | 454 | owner->host[len] = 0; |
| 455 | 455 | ||
| @@ -1018,7 +1018,7 @@ If STRING is multibyte and contains a character of charset | |||
| 1018 | if (STRING_MULTIBYTE (string)) | 1018 | if (STRING_MULTIBYTE (string)) |
| 1019 | { | 1019 | { |
| 1020 | ptrdiff_t bytes = SBYTES (string); | 1020 | ptrdiff_t bytes = SBYTES (string); |
| 1021 | unsigned char *str = (unsigned char *) xmalloc (bytes); | 1021 | unsigned char *str = xmalloc (bytes); |
| 1022 | 1022 | ||
| 1023 | memcpy (str, SDATA (string), bytes); | 1023 | memcpy (str, SDATA (string), bytes); |
| 1024 | bytes = str_as_unibyte (str, bytes); | 1024 | bytes = str_as_unibyte (str, bytes); |
| @@ -1100,7 +1100,7 @@ an error is signaled. */) | |||
| 1100 | if (STRING_MULTIBYTE (string)) | 1100 | if (STRING_MULTIBYTE (string)) |
| 1101 | { | 1101 | { |
| 1102 | ptrdiff_t chars = SCHARS (string); | 1102 | ptrdiff_t chars = SCHARS (string); |
| 1103 | unsigned char *str = (unsigned char *) xmalloc (chars); | 1103 | unsigned char *str = xmalloc (chars); |
| 1104 | ptrdiff_t converted = str_to_unibyte (SDATA (string), str, chars, 0); | 1104 | ptrdiff_t converted = str_to_unibyte (SDATA (string), str, chars, 0); |
| 1105 | 1105 | ||
| 1106 | if (converted < chars) | 1106 | if (converted < chars) |
diff --git a/src/fringe.c b/src/fringe.c index 72090dd01ca..cd3b87b43d4 100644 --- a/src/fringe.c +++ b/src/fringe.c | |||
| @@ -1639,8 +1639,7 @@ If BITMAP already exists, the existing definition is replaced. */) | |||
| 1639 | 1639 | ||
| 1640 | fb.dynamic = 1; | 1640 | fb.dynamic = 1; |
| 1641 | 1641 | ||
| 1642 | xfb = (struct fringe_bitmap *) xmalloc (sizeof fb | 1642 | xfb = xmalloc (sizeof fb + fb.height * BYTES_PER_BITMAP_ROW); |
| 1643 | + fb.height * BYTES_PER_BITMAP_ROW); | ||
| 1644 | fb.bits = b = (unsigned short *) (xfb + 1); | 1643 | fb.bits = b = (unsigned short *) (xfb + 1); |
| 1645 | memset (b, 0, fb.height); | 1644 | memset (b, 0, fb.height); |
| 1646 | 1645 | ||
| @@ -1805,15 +1804,11 @@ init_fringe (void) | |||
| 1805 | max_fringe_bitmaps = MAX_STANDARD_FRINGE_BITMAPS + 20; | 1804 | max_fringe_bitmaps = MAX_STANDARD_FRINGE_BITMAPS + 20; |
| 1806 | 1805 | ||
| 1807 | fringe_bitmaps | 1806 | fringe_bitmaps |
| 1808 | = (struct fringe_bitmap **) xmalloc (max_fringe_bitmaps * sizeof (struct fringe_bitmap *)); | 1807 | = xzalloc (max_fringe_bitmaps * sizeof (struct fringe_bitmap *)); |
| 1809 | fringe_faces | 1808 | fringe_faces = xmalloc (max_fringe_bitmaps * sizeof (Lisp_Object)); |
| 1810 | = (Lisp_Object *) xmalloc (max_fringe_bitmaps * sizeof (Lisp_Object)); | ||
| 1811 | 1809 | ||
| 1812 | for (i = 0; i < max_fringe_bitmaps; i++) | 1810 | for (i = 0; i < max_fringe_bitmaps; i++) |
| 1813 | { | 1811 | fringe_faces[i] = Qnil; |
| 1814 | fringe_bitmaps[i] = NULL; | ||
| 1815 | fringe_faces[i] = Qnil; | ||
| 1816 | } | ||
| 1817 | } | 1812 | } |
| 1818 | 1813 | ||
| 1819 | #ifdef HAVE_NTGUI | 1814 | #ifdef HAVE_NTGUI |
diff --git a/src/gtkutil.c b/src/gtkutil.c index 57453b29648..4f727ec6fa3 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -209,7 +209,7 @@ malloc_widget_value (void) | |||
| 209 | } | 209 | } |
| 210 | else | 210 | else |
| 211 | { | 211 | { |
| 212 | wv = (widget_value *) xmalloc (sizeof (widget_value)); | 212 | wv = xmalloc (sizeof (widget_value)); |
| 213 | malloc_cpt++; | 213 | malloc_cpt++; |
| 214 | } | 214 | } |
| 215 | memset (wv, 0, sizeof (widget_value)); | 215 | memset (wv, 0, sizeof (widget_value)); |
| @@ -2042,7 +2042,7 @@ make_cl_data (xg_menu_cb_data *cl_data, FRAME_PTR f, GCallback highlight_cb) | |||
| 2042 | { | 2042 | { |
| 2043 | if (! cl_data) | 2043 | if (! cl_data) |
| 2044 | { | 2044 | { |
| 2045 | cl_data = (xg_menu_cb_data*) xmalloc (sizeof (*cl_data)); | 2045 | cl_data = xmalloc (sizeof (*cl_data)); |
| 2046 | cl_data->f = f; | 2046 | cl_data->f = f; |
| 2047 | cl_data->menu_bar_vector = f->menu_bar_vector; | 2047 | cl_data->menu_bar_vector = f->menu_bar_vector; |
| 2048 | cl_data->menu_bar_items_used = f->menu_bar_items_used; | 2048 | cl_data->menu_bar_items_used = f->menu_bar_items_used; |
diff --git a/src/image.c b/src/image.c index d67faff1821..45dcb554439 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -319,7 +319,7 @@ x_create_bitmap_from_file (struct frame *f, Lisp_Object file) | |||
| 319 | id = x_allocate_bitmap_record (f); | 319 | id = x_allocate_bitmap_record (f); |
| 320 | dpyinfo->bitmaps[id - 1].img = bitmap; | 320 | dpyinfo->bitmaps[id - 1].img = bitmap; |
| 321 | dpyinfo->bitmaps[id - 1].refcount = 1; | 321 | dpyinfo->bitmaps[id - 1].refcount = 1; |
| 322 | dpyinfo->bitmaps[id - 1].file = (char *) xmalloc (SBYTES (file) + 1); | 322 | dpyinfo->bitmaps[id - 1].file = xmalloc (SBYTES (file) + 1); |
| 323 | dpyinfo->bitmaps[id - 1].depth = 1; | 323 | dpyinfo->bitmaps[id - 1].depth = 1; |
| 324 | dpyinfo->bitmaps[id - 1].height = ns_image_width (bitmap); | 324 | dpyinfo->bitmaps[id - 1].height = ns_image_width (bitmap); |
| 325 | dpyinfo->bitmaps[id - 1].width = ns_image_height (bitmap); | 325 | dpyinfo->bitmaps[id - 1].width = ns_image_height (bitmap); |
| @@ -365,7 +365,7 @@ x_create_bitmap_from_file (struct frame *f, Lisp_Object file) | |||
| 365 | dpyinfo->bitmaps[id - 1].pixmap = bitmap; | 365 | dpyinfo->bitmaps[id - 1].pixmap = bitmap; |
| 366 | dpyinfo->bitmaps[id - 1].have_mask = 0; | 366 | dpyinfo->bitmaps[id - 1].have_mask = 0; |
| 367 | dpyinfo->bitmaps[id - 1].refcount = 1; | 367 | dpyinfo->bitmaps[id - 1].refcount = 1; |
| 368 | dpyinfo->bitmaps[id - 1].file = (char *) xmalloc (SBYTES (file) + 1); | 368 | dpyinfo->bitmaps[id - 1].file = xmalloc (SBYTES (file) + 1); |
| 369 | dpyinfo->bitmaps[id - 1].depth = 1; | 369 | dpyinfo->bitmaps[id - 1].depth = 1; |
| 370 | dpyinfo->bitmaps[id - 1].height = height; | 370 | dpyinfo->bitmaps[id - 1].height = height; |
| 371 | dpyinfo->bitmaps[id - 1].width = width; | 371 | dpyinfo->bitmaps[id - 1].width = width; |
| @@ -599,7 +599,7 @@ define_image_type (struct image_type *type, int loaded) | |||
| 599 | { | 599 | { |
| 600 | /* Make a copy of TYPE to avoid a bus error in a dumped Emacs. | 600 | /* Make a copy of TYPE to avoid a bus error in a dumped Emacs. |
| 601 | The initialized data segment is read-only. */ | 601 | The initialized data segment is read-only. */ |
| 602 | struct image_type *p = (struct image_type *) xmalloc (sizeof *p); | 602 | struct image_type *p = xmalloc (sizeof *p); |
| 603 | memcpy (p, type, sizeof *p); | 603 | memcpy (p, type, sizeof *p); |
| 604 | p->next = image_types; | 604 | p->next = image_types; |
| 605 | image_types = p; | 605 | image_types = p; |
| @@ -982,11 +982,10 @@ static void free_image (struct frame *f, struct image *img); | |||
| 982 | static struct image * | 982 | static struct image * |
| 983 | make_image (Lisp_Object spec, EMACS_UINT hash) | 983 | make_image (Lisp_Object spec, EMACS_UINT hash) |
| 984 | { | 984 | { |
| 985 | struct image *img = (struct image *) xmalloc (sizeof *img); | 985 | struct image *img = xzalloc (sizeof *img); |
| 986 | Lisp_Object file = image_spec_value (spec, QCfile, NULL); | 986 | Lisp_Object file = image_spec_value (spec, QCfile, NULL); |
| 987 | 987 | ||
| 988 | eassert (valid_image_p (spec)); | 988 | eassert (valid_image_p (spec)); |
| 989 | memset (img, 0, sizeof *img); | ||
| 990 | img->dependencies = NILP (file) ? Qnil : list1 (file); | 989 | img->dependencies = NILP (file) ? Qnil : list1 (file); |
| 991 | img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL)); | 990 | img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL)); |
| 992 | eassert (img->type != NULL); | 991 | eassert (img->type != NULL); |
| @@ -1385,16 +1384,14 @@ static void postprocess_image (struct frame *, struct image *); | |||
| 1385 | struct image_cache * | 1384 | struct image_cache * |
| 1386 | make_image_cache (void) | 1385 | make_image_cache (void) |
| 1387 | { | 1386 | { |
| 1388 | struct image_cache *c = (struct image_cache *) xmalloc (sizeof *c); | 1387 | struct image_cache *c = xzalloc (sizeof *c); |
| 1389 | int size; | 1388 | int size; |
| 1390 | 1389 | ||
| 1391 | memset (c, 0, sizeof *c); | ||
| 1392 | size = 50; | 1390 | size = 50; |
| 1393 | c->images = (struct image **) xmalloc (size * sizeof *c->images); | 1391 | c->images = xmalloc (size * sizeof *c->images); |
| 1394 | c->size = size; | 1392 | c->size = size; |
| 1395 | size = IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; | 1393 | size = IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; |
| 1396 | c->buckets = (struct image **) xmalloc (size); | 1394 | c->buckets = xzalloc (size); |
| 1397 | memset (c->buckets, 0, size); | ||
| 1398 | return c; | 1395 | return c; |
| 1399 | } | 1396 | } |
| 1400 | 1397 | ||
| @@ -1969,7 +1966,7 @@ x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth, | |||
| 1969 | } | 1966 | } |
| 1970 | 1967 | ||
| 1971 | /* Allocate image raster. */ | 1968 | /* Allocate image raster. */ |
| 1972 | (*ximg)->data = (char *) xmalloc ((*ximg)->bytes_per_line * height); | 1969 | (*ximg)->data = xmalloc ((*ximg)->bytes_per_line * height); |
| 1973 | 1970 | ||
| 1974 | /* Allocate a pixmap of the same size. */ | 1971 | /* Allocate a pixmap of the same size. */ |
| 1975 | *pixmap = XCreatePixmap (display, window, width, height, depth); | 1972 | *pixmap = XCreatePixmap (display, window, width, height, depth); |
| @@ -2183,7 +2180,7 @@ slurp_file (char *file, ptrdiff_t *size) | |||
| 2183 | if (stat (file, &st) == 0 | 2180 | if (stat (file, &st) == 0 |
| 2184 | && (fp = fopen (file, "rb")) != NULL | 2181 | && (fp = fopen (file, "rb")) != NULL |
| 2185 | && 0 <= st.st_size && st.st_size <= min (PTRDIFF_MAX, SIZE_MAX) | 2182 | && 0 <= st.st_size && st.st_size <= min (PTRDIFF_MAX, SIZE_MAX) |
| 2186 | && (buf = (unsigned char *) xmalloc (st.st_size), | 2183 | && (buf = xmalloc (st.st_size), |
| 2187 | fread (buf, 1, st.st_size, fp) == st.st_size)) | 2184 | fread (buf, 1, st.st_size, fp) == st.st_size)) |
| 2188 | { | 2185 | { |
| 2189 | *size = st.st_size; | 2186 | *size = st.st_size; |
| @@ -2705,7 +2702,7 @@ xbm_read_bitmap_data (struct frame *f, unsigned char *contents, unsigned char *e | |||
| 2705 | } | 2702 | } |
| 2706 | bytes_per_line = (*width + 7) / 8 + padding_p; | 2703 | bytes_per_line = (*width + 7) / 8 + padding_p; |
| 2707 | nbytes = bytes_per_line * *height; | 2704 | nbytes = bytes_per_line * *height; |
| 2708 | p = *data = (char *) xmalloc (nbytes); | 2705 | p = *data = xmalloc (nbytes); |
| 2709 | 2706 | ||
| 2710 | if (v10) | 2707 | if (v10) |
| 2711 | { | 2708 | { |
| @@ -3118,8 +3115,7 @@ static void | |||
| 3118 | xpm_init_color_cache (struct frame *f, XpmAttributes *attrs) | 3115 | xpm_init_color_cache (struct frame *f, XpmAttributes *attrs) |
| 3119 | { | 3116 | { |
| 3120 | size_t nbytes = XPM_COLOR_CACHE_BUCKETS * sizeof *xpm_color_cache; | 3117 | size_t nbytes = XPM_COLOR_CACHE_BUCKETS * sizeof *xpm_color_cache; |
| 3121 | xpm_color_cache = (struct xpm_cached_color **) xmalloc (nbytes); | 3118 | xpm_color_cache = xzalloc (nbytes); |
| 3122 | memset (xpm_color_cache, 0, nbytes); | ||
| 3123 | init_color_table (); | 3119 | init_color_table (); |
| 3124 | 3120 | ||
| 3125 | if (attrs->valuemask & XpmColorSymbols) | 3121 | if (attrs->valuemask & XpmColorSymbols) |
| @@ -3183,7 +3179,7 @@ xpm_cache_color (struct frame *f, char *color_name, XColor *color, int bucket) | |||
| 3183 | bucket = xpm_color_bucket (color_name); | 3179 | bucket = xpm_color_bucket (color_name); |
| 3184 | 3180 | ||
| 3185 | nbytes = offsetof (struct xpm_cached_color, name) + strlen (color_name) + 1; | 3181 | nbytes = offsetof (struct xpm_cached_color, name) + strlen (color_name) + 1; |
| 3186 | p = (struct xpm_cached_color *) xmalloc (nbytes); | 3182 | p = xmalloc (nbytes); |
| 3187 | strcpy (p->name, color_name); | 3183 | strcpy (p->name, color_name); |
| 3188 | p->color = *color; | 3184 | p->color = *color; |
| 3189 | p->next = xpm_color_cache[bucket]; | 3185 | p->next = xpm_color_cache[bucket]; |
| @@ -4154,8 +4150,7 @@ static void | |||
| 4154 | init_color_table (void) | 4150 | init_color_table (void) |
| 4155 | { | 4151 | { |
| 4156 | int size = CT_SIZE * sizeof (*ct_table); | 4152 | int size = CT_SIZE * sizeof (*ct_table); |
| 4157 | ct_table = (struct ct_color **) xmalloc (size); | 4153 | ct_table = xzalloc (size); |
| 4158 | memset (ct_table, 0, size); | ||
| 4159 | ct_colors_allocated = 0; | 4154 | ct_colors_allocated = 0; |
| 4160 | } | 4155 | } |
| 4161 | 4156 | ||
| @@ -4250,7 +4245,7 @@ lookup_rgb_color (struct frame *f, int r, int g, int b) | |||
| 4250 | if (rc) | 4245 | if (rc) |
| 4251 | { | 4246 | { |
| 4252 | ++ct_colors_allocated; | 4247 | ++ct_colors_allocated; |
| 4253 | p = (struct ct_color *) xmalloc (sizeof *p); | 4248 | p = xmalloc (sizeof *p); |
| 4254 | p->r = r; | 4249 | p->r = r; |
| 4255 | p->g = g; | 4250 | p->g = g; |
| 4256 | p->b = b; | 4251 | p->b = b; |
| @@ -4268,7 +4263,7 @@ lookup_rgb_color (struct frame *f, int r, int g, int b) | |||
| 4268 | color = RGB_TO_ULONG (r, g, b); | 4263 | color = RGB_TO_ULONG (r, g, b); |
| 4269 | #endif /* HAVE_NTGUI */ | 4264 | #endif /* HAVE_NTGUI */ |
| 4270 | ++ct_colors_allocated; | 4265 | ++ct_colors_allocated; |
| 4271 | p = (struct ct_color *) xmalloc (sizeof *p); | 4266 | p = xmalloc (sizeof *p); |
| 4272 | p->r = r; | 4267 | p->r = r; |
| 4273 | p->g = g; | 4268 | p->g = g; |
| 4274 | p->b = b; | 4269 | p->b = b; |
| @@ -4323,7 +4318,7 @@ lookup_pixel_color (struct frame *f, unsigned long pixel) | |||
| 4323 | { | 4318 | { |
| 4324 | ++ct_colors_allocated; | 4319 | ++ct_colors_allocated; |
| 4325 | 4320 | ||
| 4326 | p = (struct ct_color *) xmalloc (sizeof *p); | 4321 | p = xmalloc (sizeof *p); |
| 4327 | p->r = color.red; | 4322 | p->r = color.red; |
| 4328 | p->g = color.green; | 4323 | p->g = color.green; |
| 4329 | p->b = color.blue; | 4324 | p->b = color.blue; |
| @@ -4355,8 +4350,7 @@ colors_in_color_table (int *n) | |||
| 4355 | } | 4350 | } |
| 4356 | else | 4351 | else |
| 4357 | { | 4352 | { |
| 4358 | colors = (unsigned long *) xmalloc (ct_colors_allocated | 4353 | colors = xmalloc (ct_colors_allocated * sizeof *colors); |
| 4359 | * sizeof *colors); | ||
| 4360 | *n = ct_colors_allocated; | 4354 | *n = ct_colors_allocated; |
| 4361 | 4355 | ||
| 4362 | for (i = j = 0; i < CT_SIZE; ++i) | 4356 | for (i = j = 0; i < CT_SIZE; ++i) |
| @@ -4445,7 +4439,7 @@ x_to_xcolors (struct frame *f, struct image *img, int rgb_p) | |||
| 4445 | 4439 | ||
| 4446 | if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *colors / img->width < img->height) | 4440 | if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *colors / img->width < img->height) |
| 4447 | memory_full (SIZE_MAX); | 4441 | memory_full (SIZE_MAX); |
| 4448 | colors = (XColor *) xmalloc (sizeof *colors * img->width * img->height); | 4442 | colors = xmalloc (sizeof *colors * img->width * img->height); |
| 4449 | 4443 | ||
| 4450 | #ifndef HAVE_NTGUI | 4444 | #ifndef HAVE_NTGUI |
| 4451 | /* Get the X image IMG->pixmap. */ | 4445 | /* Get the X image IMG->pixmap. */ |
| @@ -4599,7 +4593,7 @@ x_detect_edges (struct frame *f, struct image *img, int *matrix, int color_adjus | |||
| 4599 | 4593 | ||
| 4600 | if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *new / img->width < img->height) | 4594 | if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *new / img->width < img->height) |
| 4601 | memory_full (SIZE_MAX); | 4595 | memory_full (SIZE_MAX); |
| 4602 | new = (XColor *) xmalloc (sizeof *new * img->width * img->height); | 4596 | new = xmalloc (sizeof *new * img->width * img->height); |
| 4603 | 4597 | ||
| 4604 | for (y = 0; y < img->height; ++y) | 4598 | for (y = 0; y < img->height; ++y) |
| 4605 | { | 4599 | { |
| @@ -4852,8 +4846,7 @@ x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how) | |||
| 4852 | #else | 4846 | #else |
| 4853 | /* Create the bit array serving as mask. */ | 4847 | /* Create the bit array serving as mask. */ |
| 4854 | row_width = (img->width + 7) / 8; | 4848 | row_width = (img->width + 7) / 8; |
| 4855 | mask_img = xmalloc (row_width * img->height); | 4849 | mask_img = xzalloc (row_width * img->height); |
| 4856 | memset (mask_img, 0, row_width * img->height); | ||
| 4857 | 4850 | ||
| 4858 | /* Create a memory device context for IMG->pixmap. */ | 4851 | /* Create a memory device context for IMG->pixmap. */ |
| 4859 | frame_dc = get_frame_dc (f); | 4852 | frame_dc = get_frame_dc (f); |
| @@ -5069,7 +5062,7 @@ pbm_read_file (Lisp_Object file, int *size) | |||
| 5069 | if (stat (SDATA (file), &st) == 0 | 5062 | if (stat (SDATA (file), &st) == 0 |
| 5070 | && (fp = fopen (SDATA (file), "rb")) != NULL | 5063 | && (fp = fopen (SDATA (file), "rb")) != NULL |
| 5071 | && 0 <= st.st_size && st.st_size <= min (PTRDIFF_MAX, SIZE_MAX) | 5064 | && 0 <= st.st_size && st.st_size <= min (PTRDIFF_MAX, SIZE_MAX) |
| 5072 | && (buf = (char *) xmalloc (st.st_size), | 5065 | && (buf = xmalloc (st.st_size), |
| 5073 | fread (buf, 1, st.st_size, fp) == st.st_size)) | 5066 | fread (buf, 1, st.st_size, fp) == st.st_size)) |
| 5074 | { | 5067 | { |
| 5075 | *size = st.st_size; | 5068 | *size = st.st_size; |
| @@ -5840,8 +5833,8 @@ png_load (struct frame *f, struct image *img) | |||
| 5840 | if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *rows < height | 5833 | if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *rows < height |
| 5841 | || min (PTRDIFF_MAX, SIZE_MAX) / sizeof *pixels / height < row_bytes) | 5834 | || min (PTRDIFF_MAX, SIZE_MAX) / sizeof *pixels / height < row_bytes) |
| 5842 | memory_full (SIZE_MAX); | 5835 | memory_full (SIZE_MAX); |
| 5843 | pixels = (png_byte *) xmalloc (sizeof *pixels * row_bytes * height); | 5836 | pixels = xmalloc (sizeof *pixels * row_bytes * height); |
| 5844 | rows = (png_byte **) xmalloc (height * sizeof *rows); | 5837 | rows = xmalloc (height * sizeof *rows); |
| 5845 | for (i = 0; i < height; ++i) | 5838 | for (i = 0; i < height; ++i) |
| 5846 | rows[i] = pixels + i * row_bytes; | 5839 | rows[i] = pixels + i * row_bytes; |
| 5847 | 5840 | ||
| @@ -6890,7 +6883,7 @@ tiff_load (struct frame *f, struct image *img) | |||
| 6890 | return 0; | 6883 | return 0; |
| 6891 | } | 6884 | } |
| 6892 | 6885 | ||
| 6893 | buf = (uint32 *) xmalloc (sizeof *buf * width * height); | 6886 | buf = xmalloc (sizeof *buf * width * height); |
| 6894 | 6887 | ||
| 6895 | rc = fn_TIFFReadRGBAImage (tiff, width, height, buf, 0); | 6888 | rc = fn_TIFFReadRGBAImage (tiff, width, height, buf, 0); |
| 6896 | 6889 | ||
diff --git a/src/keyboard.c b/src/keyboard.c index 65b7d538358..0d686e299c5 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -884,8 +884,7 @@ static struct kboard_stack *kboard_stack; | |||
| 884 | void | 884 | void |
| 885 | push_kboard (struct kboard *k) | 885 | push_kboard (struct kboard *k) |
| 886 | { | 886 | { |
| 887 | struct kboard_stack *p | 887 | struct kboard_stack *p = xmalloc (sizeof (struct kboard_stack)); |
| 888 | = (struct kboard_stack *) xmalloc (sizeof (struct kboard_stack)); | ||
| 889 | 888 | ||
| 890 | p->next = kboard_stack; | 889 | p->next = kboard_stack; |
| 891 | p->kboard = current_kboard; | 890 | p->kboard = current_kboard; |
| @@ -8323,7 +8322,7 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item) | |||
| 8323 | const char *capt = STRINGP (tcapt) ? SSDATA (tcapt) : ""; | 8322 | const char *capt = STRINGP (tcapt) ? SSDATA (tcapt) : ""; |
| 8324 | ptrdiff_t max_lbl = | 8323 | ptrdiff_t max_lbl = |
| 8325 | 2 * max (0, min (tool_bar_max_label_size, STRING_BYTES_BOUND / 2)); | 8324 | 2 * max (0, min (tool_bar_max_label_size, STRING_BYTES_BOUND / 2)); |
| 8326 | char *buf = (char *) xmalloc (max_lbl + 1); | 8325 | char *buf = xmalloc (max_lbl + 1); |
| 8327 | Lisp_Object new_lbl; | 8326 | Lisp_Object new_lbl; |
| 8328 | ptrdiff_t caption_len = strlen (capt); | 8327 | ptrdiff_t caption_len = strlen (capt); |
| 8329 | 8328 | ||
| @@ -12188,7 +12187,7 @@ variable are `sigusr1' and `sigusr2'. */); | |||
| 12188 | Vdebug_on_event = intern_c_string ("sigusr2"); | 12187 | Vdebug_on_event = intern_c_string ("sigusr2"); |
| 12189 | 12188 | ||
| 12190 | /* Create the initial keyboard. */ | 12189 | /* Create the initial keyboard. */ |
| 12191 | initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); | 12190 | initial_kboard = xmalloc (sizeof (KBOARD)); |
| 12192 | init_kboard (initial_kboard); | 12191 | init_kboard (initial_kboard); |
| 12193 | /* Vwindow_system is left at t for now. */ | 12192 | /* Vwindow_system is left at t for now. */ |
| 12194 | initial_kboard->next_kboard = all_kboards; | 12193 | initial_kboard->next_kboard = all_kboards; |
diff --git a/src/lisp.h b/src/lisp.h index 9b2dda244e9..332ac298ce3 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -3237,6 +3237,7 @@ extern int initialized; | |||
| 3237 | extern int immediate_quit; /* Nonzero means ^G can quit instantly */ | 3237 | extern int immediate_quit; /* Nonzero means ^G can quit instantly */ |
| 3238 | 3238 | ||
| 3239 | extern void *xmalloc (size_t); | 3239 | extern void *xmalloc (size_t); |
| 3240 | extern void *xzalloc (size_t); | ||
| 3240 | extern void *xrealloc (void *, size_t); | 3241 | extern void *xrealloc (void *, size_t); |
| 3241 | extern void xfree (void *); | 3242 | extern void xfree (void *); |
| 3242 | extern void *xnmalloc (ptrdiff_t, ptrdiff_t); | 3243 | extern void *xnmalloc (ptrdiff_t, ptrdiff_t); |
| @@ -3352,7 +3353,7 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object); | |||
| 3352 | buf = (type) alloca (size); \ | 3353 | buf = (type) alloca (size); \ |
| 3353 | else \ | 3354 | else \ |
| 3354 | { \ | 3355 | { \ |
| 3355 | buf = (type) xmalloc (size); \ | 3356 | buf = xmalloc (size); \ |
| 3356 | sa_must_free = 1; \ | 3357 | sa_must_free = 1; \ |
| 3357 | record_unwind_protect (safe_alloca_unwind, \ | 3358 | record_unwind_protect (safe_alloca_unwind, \ |
| 3358 | make_save_value (buf, 0)); \ | 3359 | make_save_value (buf, 0)); \ |
| @@ -3396,7 +3397,7 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object); | |||
| 3396 | else if ((nelt) < min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object)) \ | 3397 | else if ((nelt) < min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object)) \ |
| 3397 | { \ | 3398 | { \ |
| 3398 | Lisp_Object arg_; \ | 3399 | Lisp_Object arg_; \ |
| 3399 | buf = (Lisp_Object *) xmalloc ((nelt) * sizeof (Lisp_Object)); \ | 3400 | buf = xmalloc ((nelt) * sizeof (Lisp_Object)); \ |
| 3400 | arg_ = make_save_value (buf, nelt); \ | 3401 | arg_ = make_save_value (buf, nelt); \ |
| 3401 | XSAVE_VALUE (arg_)->dogc = 1; \ | 3402 | XSAVE_VALUE (arg_)->dogc = 1; \ |
| 3402 | sa_must_free = 1; \ | 3403 | sa_must_free = 1; \ |
diff --git a/src/lread.c b/src/lread.c index 1e496bf9742..670831081e8 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -2625,7 +2625,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2625 | 2625 | ||
| 2626 | if (saved_doc_string_size == 0) | 2626 | if (saved_doc_string_size == 0) |
| 2627 | { | 2627 | { |
| 2628 | saved_doc_string = (char *) xmalloc (nskip + extra); | 2628 | saved_doc_string = xmalloc (nskip + extra); |
| 2629 | saved_doc_string_size = nskip + extra; | 2629 | saved_doc_string_size = nskip + extra; |
| 2630 | } | 2630 | } |
| 2631 | if (nskip > saved_doc_string_size) | 2631 | if (nskip > saved_doc_string_size) |
| @@ -3966,7 +3966,7 @@ init_obarray (void) | |||
| 3966 | 3966 | ||
| 3967 | DEFSYM (Qvariable_documentation, "variable-documentation"); | 3967 | DEFSYM (Qvariable_documentation, "variable-documentation"); |
| 3968 | 3968 | ||
| 3969 | read_buffer = (char *) xmalloc (size); | 3969 | read_buffer = xmalloc (size); |
| 3970 | read_buffer_size = size; | 3970 | read_buffer_size = size; |
| 3971 | } | 3971 | } |
| 3972 | 3972 | ||
diff --git a/src/minibuf.c b/src/minibuf.c index 7df230341dd..050a22a418d 100644 --- a/src/minibuf.c +++ b/src/minibuf.c | |||
| @@ -248,7 +248,7 @@ read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial, | |||
| 248 | val = Qnil; | 248 | val = Qnil; |
| 249 | size = 100; | 249 | size = 100; |
| 250 | len = 0; | 250 | len = 0; |
| 251 | line = (char *) xmalloc (size); | 251 | line = xmalloc (size); |
| 252 | 252 | ||
| 253 | while ((c = getchar ()) != '\n') | 253 | while ((c = getchar ()) != '\n') |
| 254 | { | 254 | { |
diff --git a/src/msdos.c b/src/msdos.c index ba26b7462e4..64fc671fa43 100644 --- a/src/msdos.c +++ b/src/msdos.c | |||
| @@ -2828,7 +2828,7 @@ IT_menu_create (void) | |||
| 2828 | { | 2828 | { |
| 2829 | XMenu *menu; | 2829 | XMenu *menu; |
| 2830 | 2830 | ||
| 2831 | menu = (XMenu *) xmalloc (sizeof (XMenu)); | 2831 | menu = xmalloc (sizeof (XMenu)); |
| 2832 | menu->allocated = menu->count = menu->panecount = menu->width = 0; | 2832 | menu->allocated = menu->count = menu->panecount = menu->width = 0; |
| 2833 | return menu; | 2833 | return menu; |
| 2834 | } | 2834 | } |
| @@ -2842,10 +2842,10 @@ IT_menu_make_room (XMenu *menu) | |||
| 2842 | if (menu->allocated == 0) | 2842 | if (menu->allocated == 0) |
| 2843 | { | 2843 | { |
| 2844 | int count = menu->allocated = 10; | 2844 | int count = menu->allocated = 10; |
| 2845 | menu->text = (char **) xmalloc (count * sizeof (char *)); | 2845 | menu->text = xmalloc (count * sizeof (char *)); |
| 2846 | menu->submenu = (XMenu **) xmalloc (count * sizeof (XMenu *)); | 2846 | menu->submenu = xmalloc (count * sizeof (XMenu *)); |
| 2847 | menu->panenumber = (int *) xmalloc (count * sizeof (int)); | 2847 | menu->panenumber = xmalloc (count * sizeof (int)); |
| 2848 | menu->help_text = (const char **) xmalloc (count * sizeof (char *)); | 2848 | menu->help_text = xmalloc (count * sizeof (char *)); |
| 2849 | } | 2849 | } |
| 2850 | else if (menu->allocated == menu->count) | 2850 | else if (menu->allocated == menu->count) |
| 2851 | { | 2851 | { |
| @@ -2926,7 +2926,7 @@ IT_menu_display (XMenu *menu, int y, int x, int pn, int *faces, int disp_help) | |||
| 2926 | width = menu->width; | 2926 | width = menu->width; |
| 2927 | /* We multiply width by 2 to account for possible control characters. | 2927 | /* We multiply width by 2 to account for possible control characters. |
| 2928 | FIXME: cater to non-ASCII characters in menus. */ | 2928 | FIXME: cater to non-ASCII characters in menus. */ |
| 2929 | text = (struct glyph *) xmalloc ((width * 2 + 2) * sizeof (struct glyph)); | 2929 | text = xmalloc ((width * 2 + 2) * sizeof (struct glyph)); |
| 2930 | ScreenGetCursor (&row, &col); | 2930 | ScreenGetCursor (&row, &col); |
| 2931 | mouse_get_xy (&mx, &my); | 2931 | mouse_get_xy (&mx, &my); |
| 2932 | IT_update_begin (sf); | 2932 | IT_update_begin (sf); |
diff --git a/src/print.c b/src/print.c index e12313688f5..b0189b9bc20 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -157,7 +157,7 @@ int print_output_debug_flag EXTERNALLY_VISIBLE = 1; | |||
| 157 | else \ | 157 | else \ |
| 158 | { \ | 158 | { \ |
| 159 | int new_size = 1000; \ | 159 | int new_size = 1000; \ |
| 160 | print_buffer = (char *) xmalloc (new_size); \ | 160 | print_buffer = xmalloc (new_size); \ |
| 161 | print_buffer_size = new_size; \ | 161 | print_buffer_size = new_size; \ |
| 162 | free_print_buffer = 1; \ | 162 | free_print_buffer = 1; \ |
| 163 | } \ | 163 | } \ |
diff --git a/src/process.c b/src/process.c index a251e08a4db..3f329872c76 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -3316,7 +3316,7 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3316 | { | 3316 | { |
| 3317 | if (datagram_address[s].sa) | 3317 | if (datagram_address[s].sa) |
| 3318 | abort (); | 3318 | abort (); |
| 3319 | datagram_address[s].sa = (struct sockaddr *) xmalloc (lres->ai_addrlen); | 3319 | datagram_address[s].sa = xmalloc (lres->ai_addrlen); |
| 3320 | datagram_address[s].len = lres->ai_addrlen; | 3320 | datagram_address[s].len = lres->ai_addrlen; |
| 3321 | if (is_server) | 3321 | if (is_server) |
| 3322 | { | 3322 | { |
| @@ -6286,7 +6286,7 @@ process has been transmitted to the serial port. */) | |||
| 6286 | 6286 | ||
| 6287 | if (!proc_encode_coding_system[new_outfd]) | 6287 | if (!proc_encode_coding_system[new_outfd]) |
| 6288 | proc_encode_coding_system[new_outfd] | 6288 | proc_encode_coding_system[new_outfd] |
| 6289 | = (struct coding_system *) xmalloc (sizeof (struct coding_system)); | 6289 | = xmalloc (sizeof (struct coding_system)); |
| 6290 | memcpy (proc_encode_coding_system[new_outfd], | 6290 | memcpy (proc_encode_coding_system[new_outfd], |
| 6291 | proc_encode_coding_system[old_outfd], | 6291 | proc_encode_coding_system[old_outfd], |
| 6292 | sizeof (struct coding_system)); | 6292 | sizeof (struct coding_system)); |
| @@ -7084,7 +7084,7 @@ setup_process_coding_systems (Lisp_Object process) | |||
| 7084 | 7084 | ||
| 7085 | if (!proc_decode_coding_system[inch]) | 7085 | if (!proc_decode_coding_system[inch]) |
| 7086 | proc_decode_coding_system[inch] | 7086 | proc_decode_coding_system[inch] |
| 7087 | = (struct coding_system *) xmalloc (sizeof (struct coding_system)); | 7087 | = xmalloc (sizeof (struct coding_system)); |
| 7088 | coding_system = p->decode_coding_system; | 7088 | coding_system = p->decode_coding_system; |
| 7089 | if (! NILP (p->filter)) | 7089 | if (! NILP (p->filter)) |
| 7090 | ; | 7090 | ; |
| @@ -7097,7 +7097,7 @@ setup_process_coding_systems (Lisp_Object process) | |||
| 7097 | 7097 | ||
| 7098 | if (!proc_encode_coding_system[outch]) | 7098 | if (!proc_encode_coding_system[outch]) |
| 7099 | proc_encode_coding_system[outch] | 7099 | proc_encode_coding_system[outch] |
| 7100 | = (struct coding_system *) xmalloc (sizeof (struct coding_system)); | 7100 | = xmalloc (sizeof (struct coding_system)); |
| 7101 | setup_coding_system (p->encode_coding_system, | 7101 | setup_coding_system (p->encode_coding_system, |
| 7102 | proc_encode_coding_system[outch]); | 7102 | proc_encode_coding_system[outch]); |
| 7103 | #endif | 7103 | #endif |
diff --git a/src/region-cache.c b/src/region-cache.c index 2642e824680..a3a2a072c8c 100644 --- a/src/region-cache.c +++ b/src/region-cache.c | |||
| @@ -132,15 +132,13 @@ static void revalidate_region_cache (struct buffer *buf, struct region_cache *c) | |||
| 132 | struct region_cache * | 132 | struct region_cache * |
| 133 | new_region_cache (void) | 133 | new_region_cache (void) |
| 134 | { | 134 | { |
| 135 | struct region_cache *c | 135 | struct region_cache *c = xmalloc (sizeof (struct region_cache)); |
| 136 | = (struct region_cache *) xmalloc (sizeof (struct region_cache)); | ||
| 137 | 136 | ||
| 138 | c->gap_start = 0; | 137 | c->gap_start = 0; |
| 139 | c->gap_len = NEW_CACHE_GAP; | 138 | c->gap_len = NEW_CACHE_GAP; |
| 140 | c->cache_len = 0; | 139 | c->cache_len = 0; |
| 141 | c->boundaries = | 140 | c->boundaries = xmalloc ((c->gap_len + c->cache_len) |
| 142 | (struct boundary *) xmalloc ((c->gap_len + c->cache_len) | 141 | * sizeof (*c->boundaries)); |
| 143 | * sizeof (*c->boundaries)); | ||
| 144 | 142 | ||
| 145 | c->beg_unchanged = 0; | 143 | c->beg_unchanged = 0; |
| 146 | c->end_unchanged = 0; | 144 | c->end_unchanged = 0; |
diff --git a/src/search.c b/src/search.c index 11f51d87a7d..a7ea3634579 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -2064,8 +2064,8 @@ set_search_regs (ptrdiff_t beg_byte, ptrdiff_t nbytes) | |||
| 2064 | the match position. */ | 2064 | the match position. */ |
| 2065 | if (search_regs.num_regs == 0) | 2065 | if (search_regs.num_regs == 0) |
| 2066 | { | 2066 | { |
| 2067 | search_regs.start = (regoff_t *) xmalloc (2 * sizeof (regoff_t)); | 2067 | search_regs.start = xmalloc (2 * sizeof (regoff_t)); |
| 2068 | search_regs.end = (regoff_t *) xmalloc (2 * sizeof (regoff_t)); | 2068 | search_regs.end = xmalloc (2 * sizeof (regoff_t)); |
| 2069 | search_regs.num_regs = 2; | 2069 | search_regs.num_regs = 2; |
| 2070 | } | 2070 | } |
| 2071 | 2071 | ||
| @@ -2500,7 +2500,7 @@ since only regular expressions have distinguished subexpressions. */) | |||
| 2500 | substed_alloc_size = ((STRING_BYTES_BOUND - 100) / 2 < length | 2500 | substed_alloc_size = ((STRING_BYTES_BOUND - 100) / 2 < length |
| 2501 | ? STRING_BYTES_BOUND | 2501 | ? STRING_BYTES_BOUND |
| 2502 | : length * 2 + 100); | 2502 | : length * 2 + 100); |
| 2503 | substed = (unsigned char *) xmalloc (substed_alloc_size); | 2503 | substed = xmalloc (substed_alloc_size); |
| 2504 | substed_len = 0; | 2504 | substed_len = 0; |
| 2505 | 2505 | ||
| 2506 | /* Go thru NEWTEXT, producing the actual text to insert in | 2506 | /* Go thru NEWTEXT, producing the actual text to insert in |
| @@ -3040,7 +3040,7 @@ syms_of_search (void) | |||
| 3040 | for (i = 0; i < REGEXP_CACHE_SIZE; ++i) | 3040 | for (i = 0; i < REGEXP_CACHE_SIZE; ++i) |
| 3041 | { | 3041 | { |
| 3042 | searchbufs[i].buf.allocated = 100; | 3042 | searchbufs[i].buf.allocated = 100; |
| 3043 | searchbufs[i].buf.buffer = (unsigned char *) xmalloc (100); | 3043 | searchbufs[i].buf.buffer = xmalloc (100); |
| 3044 | searchbufs[i].buf.fastmap = searchbufs[i].fastmap; | 3044 | searchbufs[i].buf.fastmap = searchbufs[i].fastmap; |
| 3045 | searchbufs[i].regexp = Qnil; | 3045 | searchbufs[i].regexp = Qnil; |
| 3046 | searchbufs[i].whitespace_regexp = Qnil; | 3046 | searchbufs[i].whitespace_regexp = Qnil; |
diff --git a/src/sound.c b/src/sound.c index 66df195338f..e28e8c69f11 100644 --- a/src/sound.c +++ b/src/sound.c | |||
| @@ -1364,10 +1364,8 @@ Internal use only, use `play-sound' instead. */) | |||
| 1364 | #ifndef WINDOWSNT | 1364 | #ifndef WINDOWSNT |
| 1365 | file = Qnil; | 1365 | file = Qnil; |
| 1366 | GCPRO2 (sound, file); | 1366 | GCPRO2 (sound, file); |
| 1367 | current_sound_device = (struct sound_device *) xmalloc (sizeof (struct sound_device)); | 1367 | current_sound_device = xzalloc (sizeof (struct sound_device)); |
| 1368 | memset (current_sound_device, 0, sizeof (struct sound_device)); | 1368 | current_sound = xzalloc (sizeof (struct sound)); |
| 1369 | current_sound = (struct sound *) xmalloc (sizeof (struct sound)); | ||
| 1370 | memset (current_sound, 0, sizeof (struct sound)); | ||
| 1371 | record_unwind_protect (sound_cleanup, Qnil); | 1369 | record_unwind_protect (sound_cleanup, Qnil); |
| 1372 | current_sound->header = (char *) alloca (MAX_SOUND_HEADER_BYTES); | 1370 | current_sound->header = (char *) alloca (MAX_SOUND_HEADER_BYTES); |
| 1373 | 1371 | ||
diff --git a/src/sysdep.c b/src/sysdep.c index 29e396c914d..afab85439f3 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -851,7 +851,7 @@ init_sys_modes (struct tty_display_info *tty_out) | |||
| 851 | return; /* The tty is suspended. */ | 851 | return; /* The tty is suspended. */ |
| 852 | 852 | ||
| 853 | if (! tty_out->old_tty) | 853 | if (! tty_out->old_tty) |
| 854 | tty_out->old_tty = (struct emacs_tty *) xmalloc (sizeof (struct emacs_tty)); | 854 | tty_out->old_tty = xmalloc (sizeof (struct emacs_tty)); |
| 855 | 855 | ||
| 856 | emacs_get_tty (fileno (tty_out->input), tty_out->old_tty); | 856 | emacs_get_tty (fileno (tty_out->input), tty_out->old_tty); |
| 857 | 857 | ||
diff --git a/src/term.c b/src/term.c index 128aaca20dd..ebf2f0b341e 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -2863,8 +2863,7 @@ create_tty_output (struct frame *f) | |||
| 2863 | if (! FRAME_TERMCAP_P (f)) | 2863 | if (! FRAME_TERMCAP_P (f)) |
| 2864 | abort (); | 2864 | abort (); |
| 2865 | 2865 | ||
| 2866 | t = xmalloc (sizeof (struct tty_output)); | 2866 | t = xzalloc (sizeof (struct tty_output)); |
| 2867 | memset (t, 0, sizeof (struct tty_output)); | ||
| 2868 | 2867 | ||
| 2869 | t->display_info = FRAME_TERMINAL (f)->display_info.tty; | 2868 | t->display_info = FRAME_TERMINAL (f)->display_info.tty; |
| 2870 | 2869 | ||
| @@ -3065,9 +3064,8 @@ init_tty (const char *name, const char *terminal_type, int must_succeed) | |||
| 3065 | been_here = 1; | 3064 | been_here = 1; |
| 3066 | tty = &the_only_display_info; | 3065 | tty = &the_only_display_info; |
| 3067 | #else | 3066 | #else |
| 3068 | tty = (struct tty_display_info *) xmalloc (sizeof (struct tty_display_info)); | 3067 | tty = xzalloc (sizeof (struct tty_display_info)); |
| 3069 | #endif | 3068 | #endif |
| 3070 | memset (tty, 0, sizeof (struct tty_display_info)); | ||
| 3071 | tty->next = tty_list; | 3069 | tty->next = tty_list; |
| 3072 | tty_list = tty; | 3070 | tty_list = tty; |
| 3073 | 3071 | ||
| @@ -3075,7 +3073,7 @@ init_tty (const char *name, const char *terminal_type, int must_succeed) | |||
| 3075 | terminal->display_info.tty = tty; | 3073 | terminal->display_info.tty = tty; |
| 3076 | tty->terminal = terminal; | 3074 | tty->terminal = terminal; |
| 3077 | 3075 | ||
| 3078 | tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); | 3076 | tty->Wcm = xmalloc (sizeof (struct cm)); |
| 3079 | Wcm_clear (tty); | 3077 | Wcm_clear (tty); |
| 3080 | 3078 | ||
| 3081 | encode_terminal_src_size = 0; | 3079 | encode_terminal_src_size = 0; |
| @@ -3136,7 +3134,7 @@ init_tty (const char *name, const char *terminal_type, int must_succeed) | |||
| 3136 | 3134 | ||
| 3137 | Wcm_clear (tty); | 3135 | Wcm_clear (tty); |
| 3138 | 3136 | ||
| 3139 | tty->termcap_term_buffer = (char *) xmalloc (buffer_size); | 3137 | tty->termcap_term_buffer = xmalloc (buffer_size); |
| 3140 | 3138 | ||
| 3141 | /* On some systems, tgetent tries to access the controlling | 3139 | /* On some systems, tgetent tries to access the controlling |
| 3142 | terminal. */ | 3140 | terminal. */ |
| @@ -3177,7 +3175,7 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ | |||
| 3177 | abort (); | 3175 | abort (); |
| 3178 | buffer_size = strlen (tty->termcap_term_buffer); | 3176 | buffer_size = strlen (tty->termcap_term_buffer); |
| 3179 | #endif | 3177 | #endif |
| 3180 | tty->termcap_strings_buffer = area = (char *) xmalloc (buffer_size); | 3178 | tty->termcap_strings_buffer = area = xmalloc (buffer_size); |
| 3181 | tty->TS_ins_line = tgetstr ("al", address); | 3179 | tty->TS_ins_line = tgetstr ("al", address); |
| 3182 | tty->TS_ins_multi_lines = tgetstr ("AL", address); | 3180 | tty->TS_ins_multi_lines = tgetstr ("AL", address); |
| 3183 | tty->TS_bell = tgetstr ("bl", address); | 3181 | tty->TS_bell = tgetstr ("bl", address); |
| @@ -3345,7 +3343,7 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ | |||
| 3345 | tty->mouse_highlight.mouse_face_window = Qnil; | 3343 | tty->mouse_highlight.mouse_face_window = Qnil; |
| 3346 | #endif | 3344 | #endif |
| 3347 | 3345 | ||
| 3348 | terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); | 3346 | terminal->kboard = xmalloc (sizeof (KBOARD)); |
| 3349 | init_kboard (terminal->kboard); | 3347 | init_kboard (terminal->kboard); |
| 3350 | KVAR (terminal->kboard, Vwindow_system) = Qnil; | 3348 | KVAR (terminal->kboard, Vwindow_system) = Qnil; |
| 3351 | terminal->kboard->next_kboard = all_kboards; | 3349 | terminal->kboard->next_kboard = all_kboards; |
diff --git a/src/termcap.c b/src/termcap.c index 61f9d9a31ea..ea096d789da 100644 --- a/src/termcap.c +++ b/src/termcap.c | |||
| @@ -153,7 +153,7 @@ tgetst1 (char *ptr, char **area) | |||
| 153 | p = ptr; | 153 | p = ptr; |
| 154 | while ((c = *p++) && c != ':' && c != '\n') | 154 | while ((c = *p++) && c != ':' && c != '\n') |
| 155 | ; | 155 | ; |
| 156 | ret = (char *) xmalloc (p - ptr + 1); | 156 | ret = xmalloc (p - ptr + 1); |
| 157 | } | 157 | } |
| 158 | else | 158 | else |
| 159 | ret = *area; | 159 | ret = *area; |
| @@ -377,7 +377,7 @@ tgetent (char *bp, const char *name) | |||
| 377 | if (!bp) | 377 | if (!bp) |
| 378 | { | 378 | { |
| 379 | malloc_size = 1 + strlen (term); | 379 | malloc_size = 1 + strlen (term); |
| 380 | bp = (char *) xmalloc (malloc_size); | 380 | bp = xmalloc (malloc_size); |
| 381 | } | 381 | } |
| 382 | strcpy (bp, term); | 382 | strcpy (bp, term); |
| 383 | goto ret; | 383 | goto ret; |
| @@ -440,13 +440,13 @@ tgetent (char *bp, const char *name) | |||
| 440 | 440 | ||
| 441 | buf.size = BUFSIZE; | 441 | buf.size = BUFSIZE; |
| 442 | /* Add 1 to size to ensure room for terminating null. */ | 442 | /* Add 1 to size to ensure room for terminating null. */ |
| 443 | buf.beg = (char *) xmalloc (buf.size + 1); | 443 | buf.beg = xmalloc (buf.size + 1); |
| 444 | term = indirect ? indirect : (char *)name; | 444 | term = indirect ? indirect : (char *)name; |
| 445 | 445 | ||
| 446 | if (!bp) | 446 | if (!bp) |
| 447 | { | 447 | { |
| 448 | malloc_size = indirect ? strlen (tcenv) + 1 : buf.size; | 448 | malloc_size = indirect ? strlen (tcenv) + 1 : buf.size; |
| 449 | bp = (char *) xmalloc (malloc_size); | 449 | bp = xmalloc (malloc_size); |
| 450 | } | 450 | } |
| 451 | tc_search_point = bp1 = bp; | 451 | tc_search_point = bp1 = bp; |
| 452 | 452 | ||
diff --git a/src/terminal.c b/src/terminal.c index a3cae585d9a..4e03c162213 100644 --- a/src/terminal.c +++ b/src/terminal.c | |||
| @@ -230,10 +230,8 @@ create_terminal (void) | |||
| 230 | 230 | ||
| 231 | terminal->id = next_terminal_id++; | 231 | terminal->id = next_terminal_id++; |
| 232 | 232 | ||
| 233 | terminal->keyboard_coding = | 233 | terminal->keyboard_coding = xmalloc (sizeof (struct coding_system)); |
| 234 | (struct coding_system *) xmalloc (sizeof (struct coding_system)); | 234 | terminal->terminal_coding = xmalloc (sizeof (struct coding_system)); |
| 235 | terminal->terminal_coding = | ||
| 236 | (struct coding_system *) xmalloc (sizeof (struct coding_system)); | ||
| 237 | 235 | ||
| 238 | /* If default coding systems for the terminal and the keyboard are | 236 | /* If default coding systems for the terminal and the keyboard are |
| 239 | already defined, use them in preference to the defaults. This is | 237 | already defined, use them in preference to the defaults. This is |
diff --git a/src/tparam.c b/src/tparam.c index 4d26ef524fb..9492d9dee36 100644 --- a/src/tparam.c +++ b/src/tparam.c | |||
| @@ -98,7 +98,7 @@ tparam1 (const char *string, char *outstring, int len, | |||
| 98 | if (outlen == 0) | 98 | if (outlen == 0) |
| 99 | { | 99 | { |
| 100 | outlen = len + 40; | 100 | outlen = len + 40; |
| 101 | new = (char *) xmalloc (outlen); | 101 | new = xmalloc (outlen); |
| 102 | memcpy (new, outstring, offset); | 102 | memcpy (new, outstring, offset); |
| 103 | } | 103 | } |
| 104 | else | 104 | else |
diff --git a/src/w16select.c b/src/w16select.c index 270118358b4..2026de7421d 100644 --- a/src/w16select.c +++ b/src/w16select.c | |||
| @@ -493,7 +493,7 @@ DEFUN ("w16-set-clipboard-data", Fw16_set_clipboard_data, Sw16_set_clipboard_dat | |||
| 493 | 493 | ||
| 494 | setup_coding_system (Fcheck_coding_system (coding_system), &coding); | 494 | setup_coding_system (Fcheck_coding_system (coding_system), &coding); |
| 495 | coding.dst_bytes = nbytes * 4; | 495 | coding.dst_bytes = nbytes * 4; |
| 496 | coding.destination = (unsigned char *) xmalloc (coding.dst_bytes); | 496 | coding.destination = xmalloc (coding.dst_bytes); |
| 497 | Vnext_selection_coding_system = Qnil; | 497 | Vnext_selection_coding_system = Qnil; |
| 498 | coding.mode |= CODING_MODE_LAST_BLOCK; | 498 | coding.mode |= CODING_MODE_LAST_BLOCK; |
| 499 | dst = coding.destination; | 499 | dst = coding.destination; |
| @@ -572,7 +572,7 @@ DEFUN ("w16-get-clipboard-data", Fw16_get_clipboard_data, Sw16_get_clipboard_dat | |||
| 572 | goto unblock; | 572 | goto unblock; |
| 573 | 573 | ||
| 574 | if ((data_size = get_clipboard_data_size (CF_OEMTEXT)) == 0 || | 574 | if ((data_size = get_clipboard_data_size (CF_OEMTEXT)) == 0 || |
| 575 | (htext = (unsigned char *)xmalloc (data_size)) == 0) | 575 | (htext = xmalloc (data_size)) == 0) |
| 576 | goto closeclip; | 576 | goto closeclip; |
| 577 | 577 | ||
| 578 | /* need to know final size after '\r' chars are removed because | 578 | /* need to know final size after '\r' chars are removed because |
| @@ -1476,7 +1476,7 @@ w32_get_resource (char *key, LPDWORD lpdwtype) | |||
| 1476 | lpvalue = NULL; | 1476 | lpvalue = NULL; |
| 1477 | 1477 | ||
| 1478 | if (RegQueryValueEx (hrootkey, key, NULL, NULL, NULL, &cbData) == ERROR_SUCCESS | 1478 | if (RegQueryValueEx (hrootkey, key, NULL, NULL, NULL, &cbData) == ERROR_SUCCESS |
| 1479 | && (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL | 1479 | && (lpvalue = xmalloc (cbData)) != NULL |
| 1480 | && RegQueryValueEx (hrootkey, key, NULL, lpdwtype, lpvalue, &cbData) == ERROR_SUCCESS) | 1480 | && RegQueryValueEx (hrootkey, key, NULL, lpdwtype, lpvalue, &cbData) == ERROR_SUCCESS) |
| 1481 | { | 1481 | { |
| 1482 | RegCloseKey (hrootkey); | 1482 | RegCloseKey (hrootkey); |
| @@ -1493,7 +1493,7 @@ w32_get_resource (char *key, LPDWORD lpdwtype) | |||
| 1493 | lpvalue = NULL; | 1493 | lpvalue = NULL; |
| 1494 | 1494 | ||
| 1495 | if (RegQueryValueEx (hrootkey, key, NULL, NULL, NULL, &cbData) == ERROR_SUCCESS | 1495 | if (RegQueryValueEx (hrootkey, key, NULL, NULL, NULL, &cbData) == ERROR_SUCCESS |
| 1496 | && (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL | 1496 | && (lpvalue = xmalloc (cbData)) != NULL |
| 1497 | && RegQueryValueEx (hrootkey, key, NULL, lpdwtype, lpvalue, &cbData) == ERROR_SUCCESS) | 1497 | && RegQueryValueEx (hrootkey, key, NULL, lpdwtype, lpvalue, &cbData) == ERROR_SUCCESS) |
| 1498 | { | 1498 | { |
| 1499 | RegCloseKey (hrootkey); | 1499 | RegCloseKey (hrootkey); |
| @@ -2169,7 +2169,7 @@ GetCachedVolumeInformation (char * root_dir) | |||
| 2169 | entry if present. */ | 2169 | entry if present. */ |
| 2170 | if (info == NULL) | 2170 | if (info == NULL) |
| 2171 | { | 2171 | { |
| 2172 | info = (volume_info_data *) xmalloc (sizeof (volume_info_data)); | 2172 | info = xmalloc (sizeof (volume_info_data)); |
| 2173 | add_volume_info (root_dir, info); | 2173 | add_volume_info (root_dir, info); |
| 2174 | } | 2174 | } |
| 2175 | else | 2175 | else |
diff --git a/src/w32fns.c b/src/w32fns.c index dd81e24fbee..99eca5c77b5 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -1006,8 +1006,7 @@ w32_map_color (FRAME_PTR f, COLORREF color) | |||
| 1006 | } | 1006 | } |
| 1007 | 1007 | ||
| 1008 | /* not already mapped, so add to list and recreate Windows palette */ | 1008 | /* not already mapped, so add to list and recreate Windows palette */ |
| 1009 | list = (struct w32_palette_entry *) | 1009 | list = xmalloc (sizeof (struct w32_palette_entry)); |
| 1010 | xmalloc (sizeof (struct w32_palette_entry)); | ||
| 1011 | SET_W32_COLOR (list->entry, color); | 1010 | SET_W32_COLOR (list->entry, color); |
| 1012 | list->refcount = 1; | 1011 | list->refcount = 1; |
| 1013 | list->next = FRAME_W32_DISPLAY_INFO (f)->color_list; | 1012 | list->next = FRAME_W32_DISPLAY_INFO (f)->color_list; |
| @@ -1109,8 +1108,7 @@ w32_defined_color (FRAME_PTR f, char *color, XColor *color_def, int alloc) | |||
| 1109 | if (entry == NULL && alloc) | 1108 | if (entry == NULL && alloc) |
| 1110 | { | 1109 | { |
| 1111 | /* not already mapped, so add to list */ | 1110 | /* not already mapped, so add to list */ |
| 1112 | entry = (struct w32_palette_entry *) | 1111 | entry = xmalloc (sizeof (struct w32_palette_entry)); |
| 1113 | xmalloc (sizeof (struct w32_palette_entry)); | ||
| 1114 | SET_W32_COLOR (entry->entry, XUINT (tem)); | 1112 | SET_W32_COLOR (entry->entry, XUINT (tem)); |
| 1115 | entry->next = NULL; | 1113 | entry->next = NULL; |
| 1116 | *prev = entry; | 1114 | *prev = entry; |
| @@ -3881,7 +3879,7 @@ w32_window (struct frame *f, long window_prompting, int minibuffer_only) | |||
| 3881 | 3879 | ||
| 3882 | { | 3880 | { |
| 3883 | char *str = SSDATA (Vx_resource_name); | 3881 | char *str = SSDATA (Vx_resource_name); |
| 3884 | f->namebuf = (char *) xmalloc (strlen (str) + 1); | 3882 | f->namebuf = xmalloc (strlen (str) + 1); |
| 3885 | strcpy (f->namebuf, str); | 3883 | strcpy (f->namebuf, str); |
| 3886 | } | 3884 | } |
| 3887 | 3885 | ||
| @@ -4145,9 +4143,7 @@ This function is an internal primitive--use `make-frame' instead. */) | |||
| 4145 | f->terminal = dpyinfo->terminal; | 4143 | f->terminal = dpyinfo->terminal; |
| 4146 | 4144 | ||
| 4147 | f->output_method = output_w32; | 4145 | f->output_method = output_w32; |
| 4148 | f->output_data.w32 = | 4146 | f->output_data.w32 = xzalloc (sizeof (struct w32_output)); |
| 4149 | (struct w32_output *) xmalloc (sizeof (struct w32_output)); | ||
| 4150 | memset (f->output_data.w32, 0, sizeof (struct w32_output)); | ||
| 4151 | FRAME_FONTSET (f) = -1; | 4147 | FRAME_FONTSET (f) = -1; |
| 4152 | 4148 | ||
| 4153 | f->icon_name | 4149 | f->icon_name |
| @@ -5230,9 +5226,7 @@ x_create_tip_frame (struct w32_display_info *dpyinfo, | |||
| 5230 | counts etc. */ | 5226 | counts etc. */ |
| 5231 | f->terminal = dpyinfo->terminal; | 5227 | f->terminal = dpyinfo->terminal; |
| 5232 | f->output_method = output_w32; | 5228 | f->output_method = output_w32; |
| 5233 | f->output_data.w32 = | 5229 | f->output_data.w32 = xzalloc (sizeof (struct w32_output)); |
| 5234 | (struct w32_output *) xmalloc (sizeof (struct w32_output)); | ||
| 5235 | memset (f->output_data.w32, 0, sizeof (struct w32_output)); | ||
| 5236 | 5230 | ||
| 5237 | FRAME_FONTSET (f) = -1; | 5231 | FRAME_FONTSET (f) = -1; |
| 5238 | f->icon_name = Qnil; | 5232 | f->icon_name = Qnil; |
| @@ -6687,7 +6681,7 @@ DEFUN ("default-printer-name", Fdefault_printer_name, Sdefault_printer_name, | |||
| 6687 | return Qnil; | 6681 | return Qnil; |
| 6688 | } | 6682 | } |
| 6689 | /* Allocate memory for the PRINTER_INFO_2 struct */ | 6683 | /* Allocate memory for the PRINTER_INFO_2 struct */ |
| 6690 | ppi2 = (PRINTER_INFO_2 *) xmalloc (dwNeeded); | 6684 | ppi2 = xmalloc (dwNeeded); |
| 6691 | if (!ppi2) | 6685 | if (!ppi2) |
| 6692 | { | 6686 | { |
| 6693 | ClosePrinter (hPrn); | 6687 | ClosePrinter (hPrn); |
diff --git a/src/w32font.c b/src/w32font.c index 8badace9635..d2f8410f1de 100644 --- a/src/w32font.c +++ b/src/w32font.c | |||
| @@ -529,9 +529,7 @@ w32font_text_extents (struct font *font, unsigned *code, | |||
| 529 | if (!w32_font->cached_metrics[block]) | 529 | if (!w32_font->cached_metrics[block]) |
| 530 | { | 530 | { |
| 531 | w32_font->cached_metrics[block] | 531 | w32_font->cached_metrics[block] |
| 532 | = xmalloc (CACHE_BLOCKSIZE * sizeof (struct w32_metric_cache)); | 532 | = xzalloc (CACHE_BLOCKSIZE * sizeof (struct w32_metric_cache)); |
| 533 | memset (w32_font->cached_metrics[block], 0, | ||
| 534 | CACHE_BLOCKSIZE * sizeof (struct w32_metric_cache)); | ||
| 535 | } | 533 | } |
| 536 | 534 | ||
| 537 | char_metric = w32_font->cached_metrics[block] + pos_in_block; | 535 | char_metric = w32_font->cached_metrics[block] + pos_in_block; |
diff --git a/src/w32reg.c b/src/w32reg.c index ec251cfd837..9c727ae5ab7 100644 --- a/src/w32reg.c +++ b/src/w32reg.c | |||
| @@ -110,7 +110,7 @@ w32_get_string_resource (char *name, char *class, DWORD dwexptype) | |||
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | ok = (keyname | 112 | ok = (keyname |
| 113 | && (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL | 113 | && (lpvalue = xmalloc (cbData)) != NULL |
| 114 | && RegQueryValueEx (hrootkey, keyname, NULL, NULL, lpvalue, &cbData) == ERROR_SUCCESS); | 114 | && RegQueryValueEx (hrootkey, keyname, NULL, NULL, lpvalue, &cbData) == ERROR_SUCCESS); |
| 115 | 115 | ||
| 116 | RegCloseKey (hrootkey); | 116 | RegCloseKey (hrootkey); |
diff --git a/src/w32select.c b/src/w32select.c index 699c72b71a8..1d4a6f41bdd 100644 --- a/src/w32select.c +++ b/src/w32select.c | |||
| @@ -216,7 +216,7 @@ convert_to_handle_as_coded (Lisp_Object coding_system) | |||
| 216 | 216 | ||
| 217 | setup_windows_coding_system (coding_system, &coding); | 217 | setup_windows_coding_system (coding_system, &coding); |
| 218 | coding.dst_bytes = SBYTES (current_text) * 2; | 218 | coding.dst_bytes = SBYTES (current_text) * 2; |
| 219 | coding.destination = (unsigned char *) xmalloc (coding.dst_bytes); | 219 | coding.destination = xmalloc (coding.dst_bytes); |
| 220 | encode_coding_object (&coding, current_text, 0, 0, | 220 | encode_coding_object (&coding, current_text, 0, 0, |
| 221 | SCHARS (current_text), SBYTES (current_text), Qnil); | 221 | SCHARS (current_text), SBYTES (current_text), Qnil); |
| 222 | 222 | ||
diff --git a/src/w32term.c b/src/w32term.c index c0c137b9a9d..6f0065de9eb 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -285,8 +285,7 @@ XChangeGC (void *ignore, XGCValues *gc, unsigned long mask, | |||
| 285 | XGCValues * | 285 | XGCValues * |
| 286 | XCreateGC (void *ignore, Window window, unsigned long mask, XGCValues *xgcv) | 286 | XCreateGC (void *ignore, Window window, unsigned long mask, XGCValues *xgcv) |
| 287 | { | 287 | { |
| 288 | XGCValues *gc = (XGCValues *) xmalloc (sizeof (XGCValues)); | 288 | XGCValues *gc = xzalloc (sizeof (XGCValues)); |
| 289 | memset (gc, 0, sizeof (XGCValues)); | ||
| 290 | 289 | ||
| 291 | XChangeGC (ignore, gc, mask, xgcv); | 290 | XChangeGC (ignore, gc, mask, xgcv); |
| 292 | 291 | ||
| @@ -6060,10 +6059,8 @@ w32_initialize_display_info (Lisp_Object display_name) | |||
| 6060 | w32_display_name_list); | 6059 | w32_display_name_list); |
| 6061 | dpyinfo->name_list_element = XCAR (w32_display_name_list); | 6060 | dpyinfo->name_list_element = XCAR (w32_display_name_list); |
| 6062 | 6061 | ||
| 6063 | dpyinfo->w32_id_name | 6062 | dpyinfo->w32_id_name = xmalloc (SCHARS (Vinvocation_name) |
| 6064 | = (char *) xmalloc (SCHARS (Vinvocation_name) | 6063 | + SCHARS (Vsystem_name) + 2); |
| 6065 | + SCHARS (Vsystem_name) | ||
| 6066 | + 2); | ||
| 6067 | sprintf (dpyinfo->w32_id_name, "%s@%s", | 6064 | sprintf (dpyinfo->w32_id_name, "%s@%s", |
| 6068 | SDATA (Vinvocation_name), SDATA (Vsystem_name)); | 6065 | SDATA (Vinvocation_name), SDATA (Vsystem_name)); |
| 6069 | 6066 | ||
| @@ -6228,7 +6225,7 @@ w32_create_terminal (struct w32_display_info *dpyinfo) | |||
| 6228 | /* We don't yet support separate terminals on W32, so don't try to share | 6225 | /* We don't yet support separate terminals on W32, so don't try to share |
| 6229 | keyboards between virtual terminals that are on the same physical | 6226 | keyboards between virtual terminals that are on the same physical |
| 6230 | terminal like X does. */ | 6227 | terminal like X does. */ |
| 6231 | terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); | 6228 | terminal->kboard = xmalloc (sizeof (KBOARD)); |
| 6232 | init_kboard (terminal->kboard); | 6229 | init_kboard (terminal->kboard); |
| 6233 | KVAR (terminal->kboard, Vwindow_system) = intern ("w32"); | 6230 | KVAR (terminal->kboard, Vwindow_system) = intern ("w32"); |
| 6234 | terminal->kboard->next_kboard = all_kboards; | 6231 | terminal->kboard->next_kboard = all_kboards; |
| @@ -6280,7 +6277,7 @@ w32_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 6280 | terminal = w32_create_terminal (dpyinfo); | 6277 | terminal = w32_create_terminal (dpyinfo); |
| 6281 | 6278 | ||
| 6282 | /* Set the name of the terminal. */ | 6279 | /* Set the name of the terminal. */ |
| 6283 | terminal->name = (char *) xmalloc (SBYTES (display_name) + 1); | 6280 | terminal->name = xmalloc (SBYTES (display_name) + 1); |
| 6284 | strncpy (terminal->name, SDATA (display_name), SBYTES (display_name)); | 6281 | strncpy (terminal->name, SDATA (display_name), SBYTES (display_name)); |
| 6285 | terminal->name[SBYTES (display_name)] = 0; | 6282 | terminal->name[SBYTES (display_name)] = 0; |
| 6286 | 6283 | ||
diff --git a/src/w32uniscribe.c b/src/w32uniscribe.c index 5e5c8e88b2b..06f7b1bd192 100644 --- a/src/w32uniscribe.c +++ b/src/w32uniscribe.c | |||
| @@ -231,7 +231,7 @@ uniscribe_shape (Lisp_Object lgstring) | |||
| 231 | /* First we need to break up the glyph string into runs of glyphs that | 231 | /* First we need to break up the glyph string into runs of glyphs that |
| 232 | can be treated together. First try a single run. */ | 232 | can be treated together. First try a single run. */ |
| 233 | max_items = 2; | 233 | max_items = 2; |
| 234 | items = (SCRIPT_ITEM *) xmalloc (sizeof (SCRIPT_ITEM) * max_items + 1); | 234 | items = xmalloc (sizeof (SCRIPT_ITEM) * max_items + 1); |
| 235 | 235 | ||
| 236 | while ((result = ScriptItemize (chars, nchars, max_items, NULL, NULL, | 236 | while ((result = ScriptItemize (chars, nchars, max_items, NULL, NULL, |
| 237 | items, &nitems)) == E_OUTOFMEMORY) | 237 | items, &nitems)) == E_OUTOFMEMORY) |
diff --git a/src/widget.c b/src/widget.c index 0cb1013b971..e219c200e00 100644 --- a/src/widget.c +++ b/src/widget.c | |||
| @@ -435,7 +435,7 @@ set_frame_size (EmacsFrame ew) | |||
| 435 | flags & XNegative ? '-' : '+', x < 0 ? -x : x, | 435 | flags & XNegative ? '-' : '+', x < 0 ? -x : x, |
| 436 | flags & YNegative ? '-' : '+', y < 0 ? -y : y); | 436 | flags & YNegative ? '-' : '+', y < 0 ? -y : y); |
| 437 | len = strlen (shell_position) + 1; | 437 | len = strlen (shell_position) + 1; |
| 438 | tem = (char *) xmalloc (len); | 438 | tem = xmalloc (len); |
| 439 | strncpy (tem, shell_position, len); | 439 | strncpy (tem, shell_position, len); |
| 440 | XtVaSetValues (wmshell, XtNgeometry, tem, NULL); | 440 | XtVaSetValues (wmshell, XtNgeometry, tem, NULL); |
| 441 | } | 441 | } |
| @@ -445,7 +445,7 @@ set_frame_size (EmacsFrame ew) | |||
| 445 | char *tem; | 445 | char *tem; |
| 446 | sprintf (shell_position, "=%dx%d", pixel_width, pixel_height); | 446 | sprintf (shell_position, "=%dx%d", pixel_width, pixel_height); |
| 447 | len = strlen (shell_position) + 1; | 447 | len = strlen (shell_position) + 1; |
| 448 | tem = (char *) xmalloc (len); | 448 | tem = xmalloc (len); |
| 449 | strncpy (tem, shell_position, len); | 449 | strncpy (tem, shell_position, len); |
| 450 | XtVaSetValues (wmshell, XtNgeometry, tem, NULL); | 450 | XtVaSetValues (wmshell, XtNgeometry, tem, NULL); |
| 451 | } | 451 | } |
diff --git a/src/xdisp.c b/src/xdisp.c index ae06355ac60..8231922056f 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -29055,7 +29055,7 @@ init_xdisp (void) | |||
| 29055 | /* Allocate the buffer for frame titles. | 29055 | /* Allocate the buffer for frame titles. |
| 29056 | Also used for `format-mode-line'. */ | 29056 | Also used for `format-mode-line'. */ |
| 29057 | int size = 100; | 29057 | int size = 100; |
| 29058 | mode_line_noprop_buf = (char *) xmalloc (size); | 29058 | mode_line_noprop_buf = xmalloc (size); |
| 29059 | mode_line_noprop_buf_end = mode_line_noprop_buf + size; | 29059 | mode_line_noprop_buf_end = mode_line_noprop_buf + size; |
| 29060 | mode_line_noprop_ptr = mode_line_noprop_buf; | 29060 | mode_line_noprop_ptr = mode_line_noprop_buf; |
| 29061 | mode_line_target = MODE_LINE_DISPLAY; | 29061 | mode_line_target = MODE_LINE_DISPLAY; |
diff --git a/src/xfaces.c b/src/xfaces.c index 021d40559e5..28ef5e6cd13 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -4148,8 +4148,7 @@ lface_same_font_attributes_p (Lisp_Object *lface1, Lisp_Object *lface2) | |||
| 4148 | static struct face * | 4148 | static struct face * |
| 4149 | make_realized_face (Lisp_Object *attr) | 4149 | make_realized_face (Lisp_Object *attr) |
| 4150 | { | 4150 | { |
| 4151 | struct face *face = (struct face *) xmalloc (sizeof *face); | 4151 | struct face *face = xzalloc (sizeof *face); |
| 4152 | memset (face, 0, sizeof *face); | ||
| 4153 | face->ascii_face = face; | 4152 | face->ascii_face = face; |
| 4154 | memcpy (face->lface, attr, sizeof face->lface); | 4153 | memcpy (face->lface, attr, sizeof face->lface); |
| 4155 | return face; | 4154 | return face; |
| @@ -4294,13 +4293,11 @@ make_face_cache (struct frame *f) | |||
| 4294 | struct face_cache *c; | 4293 | struct face_cache *c; |
| 4295 | int size; | 4294 | int size; |
| 4296 | 4295 | ||
| 4297 | c = (struct face_cache *) xmalloc (sizeof *c); | 4296 | c = xzalloc (sizeof *c); |
| 4298 | memset (c, 0, sizeof *c); | ||
| 4299 | size = FACE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; | 4297 | size = FACE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; |
| 4300 | c->buckets = (struct face **) xmalloc (size); | 4298 | c->buckets = xzalloc (size); |
| 4301 | memset (c->buckets, 0, size); | ||
| 4302 | c->size = 50; | 4299 | c->size = 50; |
| 4303 | c->faces_by_id = (struct face **) xmalloc (c->size * sizeof *c->faces_by_id); | 4300 | c->faces_by_id = xmalloc (c->size * sizeof *c->faces_by_id); |
| 4304 | c->f = f; | 4301 | c->f = f; |
| 4305 | c->menu_face_changed_p = menu_face_changed_default; | 4302 | c->menu_face_changed_p = menu_face_changed_default; |
| 4306 | return c; | 4303 | return c; |
| @@ -5582,7 +5579,7 @@ realize_non_ascii_face (struct frame *f, Lisp_Object font_object, | |||
| 5582 | struct face_cache *cache = FRAME_FACE_CACHE (f); | 5579 | struct face_cache *cache = FRAME_FACE_CACHE (f); |
| 5583 | struct face *face; | 5580 | struct face *face; |
| 5584 | 5581 | ||
| 5585 | face = (struct face *) xmalloc (sizeof *face); | 5582 | face = xmalloc (sizeof *face); |
| 5586 | *face = *base_face; | 5583 | *face = *base_face; |
| 5587 | face->gc = 0; | 5584 | face->gc = 0; |
| 5588 | face->extra = NULL; | 5585 | face->extra = NULL; |
diff --git a/src/xfns.c b/src/xfns.c index 13c7070e229..e90f3099f21 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -2368,7 +2368,7 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only) | |||
| 2368 | 2368 | ||
| 2369 | { | 2369 | { |
| 2370 | char *str = SSDATA (Vx_resource_name); | 2370 | char *str = SSDATA (Vx_resource_name); |
| 2371 | f->namebuf = (char *) xmalloc (strlen (str) + 1); | 2371 | f->namebuf = xmalloc (strlen (str) + 1); |
| 2372 | strcpy (f->namebuf, str); | 2372 | strcpy (f->namebuf, str); |
| 2373 | } | 2373 | } |
| 2374 | 2374 | ||
| @@ -3129,8 +3129,7 @@ This function is an internal primitive--use `make-frame' instead. */) | |||
| 3129 | f->terminal = dpyinfo->terminal; | 3129 | f->terminal = dpyinfo->terminal; |
| 3130 | 3130 | ||
| 3131 | f->output_method = output_x_window; | 3131 | f->output_method = output_x_window; |
| 3132 | f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output)); | 3132 | f->output_data.x = xzalloc (sizeof (struct x_output)); |
| 3133 | memset (f->output_data.x, 0, sizeof (struct x_output)); | ||
| 3134 | f->output_data.x->icon_bitmap = -1; | 3133 | f->output_data.x->icon_bitmap = -1; |
| 3135 | FRAME_FONTSET (f) = -1; | 3134 | FRAME_FONTSET (f) = -1; |
| 3136 | f->output_data.x->scroll_bar_foreground_pixel = -1; | 3135 | f->output_data.x->scroll_bar_foreground_pixel = -1; |
| @@ -4615,8 +4614,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo, | |||
| 4615 | from this point on, x_destroy_window might screw up reference | 4614 | from this point on, x_destroy_window might screw up reference |
| 4616 | counts etc. */ | 4615 | counts etc. */ |
| 4617 | f->output_method = output_x_window; | 4616 | f->output_method = output_x_window; |
| 4618 | f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output)); | 4617 | f->output_data.x = xzalloc (sizeof (struct x_output)); |
| 4619 | memset (f->output_data.x, 0, sizeof (struct x_output)); | ||
| 4620 | f->output_data.x->icon_bitmap = -1; | 4618 | f->output_data.x->icon_bitmap = -1; |
| 4621 | FRAME_FONTSET (f) = -1; | 4619 | FRAME_FONTSET (f) = -1; |
| 4622 | f->output_data.x->scroll_bar_foreground_pixel = -1; | 4620 | f->output_data.x->scroll_bar_foreground_pixel = -1; |
diff --git a/src/xmenu.c b/src/xmenu.c index ad2ebc09128..b7dd547737d 100644 --- a/src/xmenu.c +++ b/src/xmenu.c | |||
| @@ -961,7 +961,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) | |||
| 961 | else if (!f->output_data.x->saved_menu_event && !deep_p) | 961 | else if (!f->output_data.x->saved_menu_event && !deep_p) |
| 962 | { | 962 | { |
| 963 | deep_p = 1; | 963 | deep_p = 1; |
| 964 | f->output_data.x->saved_menu_event = (XEvent*)xmalloc (sizeof (XEvent)); | 964 | f->output_data.x->saved_menu_event = xmalloc (sizeof (XEvent)); |
| 965 | f->output_data.x->saved_menu_event->type = 0; | 965 | f->output_data.x->saved_menu_event->type = 0; |
| 966 | } | 966 | } |
| 967 | 967 | ||
diff --git a/src/xrdb.c b/src/xrdb.c index 58ca682c757..1e68205b630 100644 --- a/src/xrdb.c +++ b/src/xrdb.c | |||
| @@ -87,7 +87,7 @@ x_get_customization_string (XrmDatabase db, const char *name, | |||
| 87 | 87 | ||
| 88 | if (result) | 88 | if (result) |
| 89 | { | 89 | { |
| 90 | char *copy = (char *) xmalloc (strlen (result) + 1); | 90 | char *copy = xmalloc (strlen (result) + 1); |
| 91 | strcpy (copy, result); | 91 | strcpy (copy, result); |
| 92 | return copy; | 92 | return copy; |
| 93 | } | 93 | } |
| @@ -132,7 +132,7 @@ magic_file_p (const char *string, ptrdiff_t string_len, const char *class, | |||
| 132 | char *lang = getenv ("LANG"); | 132 | char *lang = getenv ("LANG"); |
| 133 | 133 | ||
| 134 | ptrdiff_t path_size = 100; | 134 | ptrdiff_t path_size = 100; |
| 135 | char *path = (char *) xmalloc (path_size); | 135 | char *path = xmalloc (path_size); |
| 136 | ptrdiff_t path_len = 0; | 136 | ptrdiff_t path_len = 0; |
| 137 | 137 | ||
| 138 | const char *p = string; | 138 | const char *p = string; |
| @@ -258,7 +258,7 @@ gethomedir (void) | |||
| 258 | if (ptr == NULL) | 258 | if (ptr == NULL) |
| 259 | return xstrdup ("/"); | 259 | return xstrdup ("/"); |
| 260 | 260 | ||
| 261 | copy = (char *) xmalloc (strlen (ptr) + 2); | 261 | copy = xmalloc (strlen (ptr) + 2); |
| 262 | strcpy (copy, ptr); | 262 | strcpy (copy, ptr); |
| 263 | strcat (copy, "/"); | 263 | strcat (copy, "/"); |
| 264 | 264 | ||
| @@ -400,7 +400,7 @@ get_user_db (Display *display) | |||
| 400 | char *xdefault; | 400 | char *xdefault; |
| 401 | 401 | ||
| 402 | home = gethomedir (); | 402 | home = gethomedir (); |
| 403 | xdefault = (char *) xmalloc (strlen (home) + sizeof (".Xdefaults")); | 403 | xdefault = xmalloc (strlen (home) + sizeof (".Xdefaults")); |
| 404 | strcpy (xdefault, home); | 404 | strcpy (xdefault, home); |
| 405 | strcat (xdefault, ".Xdefaults"); | 405 | strcat (xdefault, ".Xdefaults"); |
| 406 | db = XrmGetFileDatabase (xdefault); | 406 | db = XrmGetFileDatabase (xdefault); |
diff --git a/src/xselect.c b/src/xselect.c index 4d961d73bf1..67785b26353 100644 --- a/src/xselect.c +++ b/src/xselect.c | |||
| @@ -180,16 +180,11 @@ x_queue_event (struct input_event *event) | |||
| 180 | } | 180 | } |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | queue_tmp | 183 | queue_tmp = xmalloc (sizeof (struct selection_event_queue)); |
| 184 | = (struct selection_event_queue *) xmalloc (sizeof (struct selection_event_queue)); | 184 | TRACE1 ("QUEUE SELECTION EVENT %p", queue_tmp); |
| 185 | 185 | queue_tmp->event = *event; | |
| 186 | if (queue_tmp != NULL) | 186 | queue_tmp->next = selection_queue; |
| 187 | { | 187 | selection_queue = queue_tmp; |
| 188 | TRACE1 ("QUEUE SELECTION EVENT %p", queue_tmp); | ||
| 189 | queue_tmp->event = *event; | ||
| 190 | queue_tmp->next = selection_queue; | ||
| 191 | selection_queue = queue_tmp; | ||
| 192 | } | ||
| 193 | } | 188 | } |
| 194 | 189 | ||
| 195 | /* Start queuing SELECTION_REQUEST_EVENT events. */ | 190 | /* Start queuing SELECTION_REQUEST_EVENT events. */ |
| @@ -1085,7 +1080,7 @@ static struct prop_location * | |||
| 1085 | expect_property_change (Display *display, Window window, | 1080 | expect_property_change (Display *display, Window window, |
| 1086 | Atom property, int state) | 1081 | Atom property, int state) |
| 1087 | { | 1082 | { |
| 1088 | struct prop_location *pl = (struct prop_location *) xmalloc (sizeof *pl); | 1083 | struct prop_location *pl = xmalloc (sizeof *pl); |
| 1089 | pl->identifier = ++prop_location_identifier; | 1084 | pl->identifier = ++prop_location_identifier; |
| 1090 | pl->display = display; | 1085 | pl->display = display; |
| 1091 | pl->window = window; | 1086 | pl->window = window; |
| @@ -1446,7 +1441,7 @@ receive_incremental_selection (Display *display, Window window, Atom property, | |||
| 1446 | struct prop_location *wait_object; | 1441 | struct prop_location *wait_object; |
| 1447 | if (min (PTRDIFF_MAX, SIZE_MAX) < min_size_bytes) | 1442 | if (min (PTRDIFF_MAX, SIZE_MAX) < min_size_bytes) |
| 1448 | memory_full (SIZE_MAX); | 1443 | memory_full (SIZE_MAX); |
| 1449 | *data_ret = (unsigned char *) xmalloc (min_size_bytes); | 1444 | *data_ret = xmalloc (min_size_bytes); |
| 1450 | *size_bytes_ret = min_size_bytes; | 1445 | *size_bytes_ret = min_size_bytes; |
| 1451 | 1446 | ||
| 1452 | TRACE1 ("Read %u bytes incrementally", min_size_bytes); | 1447 | TRACE1 ("Read %u bytes incrementally", min_size_bytes); |
| @@ -1780,7 +1775,7 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj, | |||
| 1780 | } | 1775 | } |
| 1781 | else if (SYMBOLP (obj)) | 1776 | else if (SYMBOLP (obj)) |
| 1782 | { | 1777 | { |
| 1783 | *data_ret = (unsigned char *) xmalloc (sizeof (Atom) + 1); | 1778 | *data_ret = xmalloc (sizeof (Atom) + 1); |
| 1784 | *format_ret = 32; | 1779 | *format_ret = 32; |
| 1785 | *size_ret = 1; | 1780 | *size_ret = 1; |
| 1786 | (*data_ret) [sizeof (Atom)] = 0; | 1781 | (*data_ret) [sizeof (Atom)] = 0; |
| @@ -1789,7 +1784,7 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj, | |||
| 1789 | } | 1784 | } |
| 1790 | else if (RANGED_INTEGERP (X_SHRT_MIN, obj, X_SHRT_MAX)) | 1785 | else if (RANGED_INTEGERP (X_SHRT_MIN, obj, X_SHRT_MAX)) |
| 1791 | { | 1786 | { |
| 1792 | *data_ret = (unsigned char *) xmalloc (sizeof (short) + 1); | 1787 | *data_ret = xmalloc (sizeof (short) + 1); |
| 1793 | *format_ret = 16; | 1788 | *format_ret = 16; |
| 1794 | *size_ret = 1; | 1789 | *size_ret = 1; |
| 1795 | (*data_ret) [sizeof (short)] = 0; | 1790 | (*data_ret) [sizeof (short)] = 0; |
| @@ -1802,7 +1797,7 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj, | |||
| 1802 | || (CONSP (XCDR (obj)) | 1797 | || (CONSP (XCDR (obj)) |
| 1803 | && INTEGERP (XCAR (XCDR (obj))))))) | 1798 | && INTEGERP (XCAR (XCDR (obj))))))) |
| 1804 | { | 1799 | { |
| 1805 | *data_ret = (unsigned char *) xmalloc (sizeof (unsigned long) + 1); | 1800 | *data_ret = xmalloc (sizeof (unsigned long) + 1); |
| 1806 | *format_ret = 32; | 1801 | *format_ret = 32; |
| 1807 | *size_ret = 1; | 1802 | *size_ret = 1; |
| 1808 | (*data_ret) [sizeof (unsigned long)] = 0; | 1803 | (*data_ret) [sizeof (unsigned long)] = 0; |
diff --git a/src/xterm.c b/src/xterm.c index 846aedc0f5b..1562ab08056 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -5777,9 +5777,9 @@ static struct x_display_info *next_noop_dpyinfo; | |||
| 5777 | do \ | 5777 | do \ |
| 5778 | { \ | 5778 | { \ |
| 5779 | if (f->output_data.x->saved_menu_event == 0) \ | 5779 | if (f->output_data.x->saved_menu_event == 0) \ |
| 5780 | f->output_data.x->saved_menu_event \ | 5780 | f->output_data.x->saved_menu_event = \ |
| 5781 | = (XEvent *) xmalloc (sizeof (XEvent)); \ | 5781 | xmalloc (sizeof (XEvent)); \ |
| 5782 | *f->output_data.x->saved_menu_event = event; \ | 5782 | *f->output_data.x->saved_menu_event = event; \ |
| 5783 | inev.ie.kind = MENU_BAR_ACTIVATE_EVENT; \ | 5783 | inev.ie.kind = MENU_BAR_ACTIVATE_EVENT; \ |
| 5784 | XSETFRAME (inev.ie.frame_or_window, f); \ | 5784 | XSETFRAME (inev.ie.frame_or_window, f); \ |
| 5785 | } \ | 5785 | } \ |
| @@ -8190,11 +8190,11 @@ xim_initialize (struct x_display_info *dpyinfo, char *resource_name) | |||
| 8190 | struct xim_inst_t *xim_inst; | 8190 | struct xim_inst_t *xim_inst; |
| 8191 | ptrdiff_t len; | 8191 | ptrdiff_t len; |
| 8192 | 8192 | ||
| 8193 | xim_inst = (struct xim_inst_t *) xmalloc (sizeof (struct xim_inst_t)); | 8193 | xim_inst = xmalloc (sizeof (struct xim_inst_t)); |
| 8194 | dpyinfo->xim_callback_data = xim_inst; | 8194 | dpyinfo->xim_callback_data = xim_inst; |
| 8195 | xim_inst->dpyinfo = dpyinfo; | 8195 | xim_inst->dpyinfo = dpyinfo; |
| 8196 | len = strlen (resource_name); | 8196 | len = strlen (resource_name); |
| 8197 | xim_inst->resource_name = (char *) xmalloc (len + 1); | 8197 | xim_inst->resource_name = xmalloc (len + 1); |
| 8198 | memcpy (xim_inst->resource_name, resource_name, len + 1); | 8198 | memcpy (xim_inst->resource_name, resource_name, len + 1); |
| 8199 | XRegisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb, | 8199 | XRegisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb, |
| 8200 | resource_name, emacs_class, | 8200 | resource_name, emacs_class, |
| @@ -10098,8 +10098,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 10098 | 10098 | ||
| 10099 | /* We have definitely succeeded. Record the new connection. */ | 10099 | /* We have definitely succeeded. Record the new connection. */ |
| 10100 | 10100 | ||
| 10101 | dpyinfo = (struct x_display_info *) xmalloc (sizeof (struct x_display_info)); | 10101 | dpyinfo = xzalloc (sizeof (struct x_display_info)); |
| 10102 | memset (dpyinfo, 0, sizeof *dpyinfo); | ||
| 10103 | hlinfo = &dpyinfo->mouse_highlight; | 10102 | hlinfo = &dpyinfo->mouse_highlight; |
| 10104 | 10103 | ||
| 10105 | terminal = x_create_terminal (dpyinfo); | 10104 | terminal = x_create_terminal (dpyinfo); |
| @@ -10117,7 +10116,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 10117 | terminal->kboard = share->terminal->kboard; | 10116 | terminal->kboard = share->terminal->kboard; |
| 10118 | else | 10117 | else |
| 10119 | { | 10118 | { |
| 10120 | terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); | 10119 | terminal->kboard = xmalloc (sizeof (KBOARD)); |
| 10121 | init_kboard (terminal->kboard); | 10120 | init_kboard (terminal->kboard); |
| 10122 | KVAR (terminal->kboard, Vwindow_system) = Qx; | 10121 | KVAR (terminal->kboard, Vwindow_system) = Qx; |
| 10123 | 10122 | ||
| @@ -10171,7 +10170,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 10171 | dpyinfo->display = dpy; | 10170 | dpyinfo->display = dpy; |
| 10172 | 10171 | ||
| 10173 | /* Set the name of the terminal. */ | 10172 | /* Set the name of the terminal. */ |
| 10174 | terminal->name = (char *) xmalloc (SBYTES (display_name) + 1); | 10173 | terminal->name = xmalloc (SBYTES (display_name) + 1); |
| 10175 | memcpy (terminal->name, SSDATA (display_name), SBYTES (display_name)); | 10174 | memcpy (terminal->name, SSDATA (display_name), SBYTES (display_name)); |
| 10176 | terminal->name[SBYTES (display_name)] = 0; | 10175 | terminal->name[SBYTES (display_name)] = 0; |
| 10177 | 10176 | ||
| @@ -10182,10 +10181,8 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 10182 | lim = min (PTRDIFF_MAX, SIZE_MAX) - sizeof "@"; | 10181 | lim = min (PTRDIFF_MAX, SIZE_MAX) - sizeof "@"; |
| 10183 | if (lim - SBYTES (Vinvocation_name) < SBYTES (Vsystem_name)) | 10182 | if (lim - SBYTES (Vinvocation_name) < SBYTES (Vsystem_name)) |
| 10184 | memory_full (SIZE_MAX); | 10183 | memory_full (SIZE_MAX); |
| 10185 | dpyinfo->x_id_name | 10184 | dpyinfo->x_id_name = xmalloc (SBYTES (Vinvocation_name) |
| 10186 | = (char *) xmalloc (SBYTES (Vinvocation_name) | 10185 | + SBYTES (Vsystem_name) + 2); |
| 10187 | + SBYTES (Vsystem_name) | ||
| 10188 | + 2); | ||
| 10189 | strcat (strcat (strcpy (dpyinfo->x_id_name, SSDATA (Vinvocation_name)), "@"), | 10186 | strcat (strcat (strcpy (dpyinfo->x_id_name, SSDATA (Vinvocation_name)), "@"), |
| 10190 | SSDATA (Vsystem_name)); | 10187 | SSDATA (Vsystem_name)); |
| 10191 | 10188 | ||