diff options
| author | Paul Eggert | 2012-07-05 11:35:48 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-07-05 11:35:48 -0700 |
| commit | 38182d901d030c7d65f4aa7a49b583afb30eb9b7 (patch) | |
| tree | a69e1a571495d6ca1c034359d7c995639774ab9b /src | |
| parent | 6dd5a677dbf794eedaa8325c46d57ac041373361 (diff) | |
| download | emacs-38182d901d030c7d65f4aa7a49b583afb30eb9b7.tar.gz emacs-38182d901d030c7d65f4aa7a49b583afb30eb9b7.zip | |
More xmalloc and related cleanup.
* alloc.c, bidi.c, buffer.c, buffer.h, bytecode.c, callint.c:
* callproc.c, charset.c, coding.c, composite.c, data.c, dispnew.c:
* doc.c, editfns.c, emacs.c, eval.c, fileio.c, filelock.c, fns.c:
* font.c, fontset.c, frame.c, fringe.c, ftfont.c, ftxfont.c, gmalloc.c:
* gtkutil.c, image.c, keyboard.c, keymap.c, lread.c, macros.c, menu.c:
* nsfns.m, nsfont.m, nsmenu.m, nsterm.m, print.c, process.c, ralloc.c:
* regex.c, region-cache.c, scroll.c, search.c, sound.c, syntax.c:
* sysdep.c, term.c, termcap.c, unexmacosx.c, window.c, xdisp.c:
* xfaces.c, xfns.c, xftfont.c, xgselect.c, xmenu.c, xrdb.c, xselect.c:
* xterm.c:
Omit needless casts involving void * pointers and allocation.
Prefer "P = xmalloc (sizeof *P)" to "P = xmalloc (sizeof (TYPE_OF_P))",
as the former is more robust if P's type is changed.
Prefer xzalloc to xmalloc + memset 0.
Simplify malloc-or-realloc to realloc.
Don't worry about xmalloc returning a null pointer.
Prefer xstrdup to xmalloc + strcpy.
* editfns.c (Fmessage_box): Grow message_text by at least 80 when
growing it.
* keyboard.c (apply_modifiers_uncached): Prefer local array to
alloca of a constant.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 25 | ||||
| -rw-r--r-- | src/alloc.c | 75 | ||||
| -rw-r--r-- | src/bidi.c | 3 | ||||
| -rw-r--r-- | src/buffer.c | 21 | ||||
| -rw-r--r-- | src/buffer.h | 4 | ||||
| -rw-r--r-- | src/bytecode.c | 3 | ||||
| -rw-r--r-- | src/callint.c | 8 | ||||
| -rw-r--r-- | src/callproc.c | 6 | ||||
| -rw-r--r-- | src/charset.c | 2 | ||||
| -rw-r--r-- | src/coding.c | 8 | ||||
| -rw-r--r-- | src/composite.c | 2 | ||||
| -rw-r--r-- | src/data.c | 3 | ||||
| -rw-r--r-- | src/dispnew.c | 33 | ||||
| -rw-r--r-- | src/doc.c | 9 | ||||
| -rw-r--r-- | src/editfns.c | 18 | ||||
| -rw-r--r-- | src/emacs.c | 2 | ||||
| -rw-r--r-- | src/eval.c | 5 | ||||
| -rw-r--r-- | src/fileio.c | 26 | ||||
| -rw-r--r-- | src/filelock.c | 2 | ||||
| -rw-r--r-- | src/fns.c | 2 | ||||
| -rw-r--r-- | src/font.c | 4 | ||||
| -rw-r--r-- | src/fontset.c | 10 | ||||
| -rw-r--r-- | src/frame.c | 33 | ||||
| -rw-r--r-- | src/fringe.c | 15 | ||||
| -rw-r--r-- | src/ftfont.c | 13 | ||||
| -rw-r--r-- | src/ftxfont.c | 2 | ||||
| -rw-r--r-- | src/gmalloc.c | 6 | ||||
| -rw-r--r-- | src/gtkutil.c | 8 | ||||
| -rw-r--r-- | src/image.c | 19 | ||||
| -rw-r--r-- | src/keyboard.c | 38 | ||||
| -rw-r--r-- | src/keymap.c | 6 | ||||
| -rw-r--r-- | src/lread.c | 14 | ||||
| -rw-r--r-- | src/macros.c | 6 | ||||
| -rw-r--r-- | src/menu.c | 5 | ||||
| -rw-r--r-- | src/nsfns.m | 3 | ||||
| -rw-r--r-- | src/nsfont.m | 20 | ||||
| -rw-r--r-- | src/nsmenu.m | 17 | ||||
| -rw-r--r-- | src/nsterm.m | 32 | ||||
| -rw-r--r-- | src/print.c | 3 | ||||
| -rw-r--r-- | src/process.c | 14 | ||||
| -rw-r--r-- | src/ralloc.c | 2 | ||||
| -rw-r--r-- | src/regex.c | 43 | ||||
| -rw-r--r-- | src/region-cache.c | 2 | ||||
| -rw-r--r-- | src/scroll.c | 10 | ||||
| -rw-r--r-- | src/search.c | 14 | ||||
| -rw-r--r-- | src/sound.c | 16 | ||||
| -rw-r--r-- | src/syntax.c | 4 | ||||
| -rw-r--r-- | src/sysdep.c | 16 | ||||
| -rw-r--r-- | src/term.c | 10 | ||||
| -rw-r--r-- | src/termcap.c | 4 | ||||
| -rw-r--r-- | src/unexmacosx.c | 8 | ||||
| -rw-r--r-- | src/window.c | 5 | ||||
| -rw-r--r-- | src/xdisp.c | 28 | ||||
| -rw-r--r-- | src/xfaces.c | 23 | ||||
| -rw-r--r-- | src/xfns.c | 14 | ||||
| -rw-r--r-- | src/xftfont.c | 2 | ||||
| -rw-r--r-- | src/xgselect.c | 2 | ||||
| -rw-r--r-- | src/xmenu.c | 18 | ||||
| -rw-r--r-- | src/xrdb.c | 12 | ||||
| -rw-r--r-- | src/xselect.c | 45 | ||||
| -rw-r--r-- | src/xterm.c | 19 |
61 files changed, 380 insertions, 442 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 1fdeee52f7f..d3035fe22a2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,28 @@ | |||
| 1 | 2012-07-05 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | More xmalloc and related cleanup. | ||
| 4 | * alloc.c, bidi.c, buffer.c, buffer.h, bytecode.c, callint.c: | ||
| 5 | * callproc.c, charset.c, coding.c, composite.c, data.c, dispnew.c: | ||
| 6 | * doc.c, editfns.c, emacs.c, eval.c, fileio.c, filelock.c, fns.c: | ||
| 7 | * font.c, fontset.c, frame.c, fringe.c, ftfont.c, ftxfont.c, gmalloc.c: | ||
| 8 | * gtkutil.c, image.c, keyboard.c, keymap.c, lread.c, macros.c, menu.c: | ||
| 9 | * nsfns.m, nsfont.m, nsmenu.m, nsterm.m, print.c, process.c, ralloc.c: | ||
| 10 | * regex.c, region-cache.c, scroll.c, search.c, sound.c, syntax.c: | ||
| 11 | * sysdep.c, term.c, termcap.c, unexmacosx.c, window.c, xdisp.c: | ||
| 12 | * xfaces.c, xfns.c, xftfont.c, xgselect.c, xmenu.c, xrdb.c, xselect.c: | ||
| 13 | * xterm.c: | ||
| 14 | Omit needless casts involving void * pointers and allocation. | ||
| 15 | Prefer "P = xmalloc (sizeof *P)" to "P = xmalloc (sizeof (TYPE_OF_P))", | ||
| 16 | as the former is more robust if P's type is changed. | ||
| 17 | Prefer xzalloc to xmalloc + memset 0. | ||
| 18 | Simplify malloc-or-realloc to realloc. | ||
| 19 | Don't worry about xmalloc returning a null pointer. | ||
| 20 | Prefer xstrdup to xmalloc + strcpy. | ||
| 21 | * editfns.c (Fmessage_box): Grow message_text by at least 80 when | ||
| 22 | growing it. | ||
| 23 | * keyboard.c (apply_modifiers_uncached): Prefer local array to | ||
| 24 | alloca of a constant. | ||
| 25 | |||
| 1 | 2012-07-05 Eli Zaretskii <eliz@gnu.org> | 26 | 2012-07-05 Eli Zaretskii <eliz@gnu.org> |
| 2 | 27 | ||
| 3 | * xdisp.c (display_line): Fix horizontal pixel coordinates when | 28 | * xdisp.c (display_line): Fix horizontal pixel coordinates when |
diff --git a/src/alloc.c b/src/alloc.c index 6ef0782ca1b..695d71c6c94 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -615,7 +615,7 @@ overrun_check_malloc (size_t size) | |||
| 615 | if (SIZE_MAX - overhead < size) | 615 | if (SIZE_MAX - overhead < size) |
| 616 | abort (); | 616 | abort (); |
| 617 | 617 | ||
| 618 | val = (unsigned char *) malloc (size + overhead); | 618 | val = malloc (size + overhead); |
| 619 | if (val && check_depth == 1) | 619 | if (val && check_depth == 1) |
| 620 | { | 620 | { |
| 621 | memcpy (val, xmalloc_overrun_check_header, XMALLOC_OVERRUN_CHECK_SIZE); | 621 | memcpy (val, xmalloc_overrun_check_header, XMALLOC_OVERRUN_CHECK_SIZE); |
| @@ -923,7 +923,7 @@ lisp_malloc (size_t nbytes, enum mem_type type) | |||
| 923 | allocated_mem_type = type; | 923 | allocated_mem_type = type; |
| 924 | #endif | 924 | #endif |
| 925 | 925 | ||
| 926 | val = (void *) malloc (nbytes); | 926 | val = malloc (nbytes); |
| 927 | 927 | ||
| 928 | #if ! USE_LSB_TAG | 928 | #if ! USE_LSB_TAG |
| 929 | /* If the memory just allocated cannot be addressed thru a Lisp | 929 | /* If the memory just allocated cannot be addressed thru a Lisp |
| @@ -1309,7 +1309,7 @@ emacs_blocked_malloc (size_t size, const void *ptr) | |||
| 1309 | __malloc_extra_blocks = malloc_hysteresis; | 1309 | __malloc_extra_blocks = malloc_hysteresis; |
| 1310 | #endif | 1310 | #endif |
| 1311 | 1311 | ||
| 1312 | value = (void *) malloc (size); | 1312 | value = malloc (size); |
| 1313 | 1313 | ||
| 1314 | #ifdef GC_MALLOC_CHECK | 1314 | #ifdef GC_MALLOC_CHECK |
| 1315 | { | 1315 | { |
| @@ -1371,7 +1371,7 @@ emacs_blocked_realloc (void *ptr, size_t size, const void *ptr2) | |||
| 1371 | dont_register_blocks = 1; | 1371 | dont_register_blocks = 1; |
| 1372 | #endif /* GC_MALLOC_CHECK */ | 1372 | #endif /* GC_MALLOC_CHECK */ |
| 1373 | 1373 | ||
| 1374 | value = (void *) realloc (ptr, size); | 1374 | value = realloc (ptr, size); |
| 1375 | 1375 | ||
| 1376 | #ifdef GC_MALLOC_CHECK | 1376 | #ifdef GC_MALLOC_CHECK |
| 1377 | dont_register_blocks = 0; | 1377 | dont_register_blocks = 0; |
| @@ -1523,10 +1523,8 @@ make_interval (void) | |||
| 1523 | { | 1523 | { |
| 1524 | if (interval_block_index == INTERVAL_BLOCK_SIZE) | 1524 | if (interval_block_index == INTERVAL_BLOCK_SIZE) |
| 1525 | { | 1525 | { |
| 1526 | register struct interval_block *newi; | 1526 | struct interval_block *newi |
| 1527 | 1527 | = lisp_malloc (sizeof *newi, MEM_TYPE_NON_LISP); | |
| 1528 | newi = (struct interval_block *) lisp_malloc (sizeof *newi, | ||
| 1529 | MEM_TYPE_NON_LISP); | ||
| 1530 | 1528 | ||
| 1531 | newi->next = interval_block; | 1529 | newi->next = interval_block; |
| 1532 | interval_block = newi; | 1530 | interval_block = newi; |
| @@ -1932,10 +1930,9 @@ allocate_string (void) | |||
| 1932 | add all the Lisp_Strings in it to the free-list. */ | 1930 | add all the Lisp_Strings in it to the free-list. */ |
| 1933 | if (string_free_list == NULL) | 1931 | if (string_free_list == NULL) |
| 1934 | { | 1932 | { |
| 1935 | struct string_block *b; | 1933 | struct string_block *b = lisp_malloc (sizeof *b, MEM_TYPE_STRING); |
| 1936 | int i; | 1934 | int i; |
| 1937 | 1935 | ||
| 1938 | b = (struct string_block *) lisp_malloc (sizeof *b, MEM_TYPE_STRING); | ||
| 1939 | b->next = string_blocks; | 1936 | b->next = string_blocks; |
| 1940 | string_blocks = b; | 1937 | string_blocks = b; |
| 1941 | 1938 | ||
| @@ -2021,7 +2018,7 @@ allocate_string_data (struct Lisp_String *s, | |||
| 2021 | mallopt (M_MMAP_MAX, 0); | 2018 | mallopt (M_MMAP_MAX, 0); |
| 2022 | #endif | 2019 | #endif |
| 2023 | 2020 | ||
| 2024 | b = (struct sblock *) lisp_malloc (size + GC_STRING_EXTRA, MEM_TYPE_NON_LISP); | 2021 | b = lisp_malloc (size + GC_STRING_EXTRA, MEM_TYPE_NON_LISP); |
| 2025 | 2022 | ||
| 2026 | #ifdef DOUG_LEA_MALLOC | 2023 | #ifdef DOUG_LEA_MALLOC |
| 2027 | /* Back to a reasonable maximum of mmap'ed areas. */ | 2024 | /* Back to a reasonable maximum of mmap'ed areas. */ |
| @@ -2039,7 +2036,7 @@ allocate_string_data (struct Lisp_String *s, | |||
| 2039 | < (needed + GC_STRING_EXTRA))) | 2036 | < (needed + GC_STRING_EXTRA))) |
| 2040 | { | 2037 | { |
| 2041 | /* Not enough room in the current sblock. */ | 2038 | /* Not enough room in the current sblock. */ |
| 2042 | b = (struct sblock *) lisp_malloc (SBLOCK_SIZE, MEM_TYPE_NON_LISP); | 2039 | b = lisp_malloc (SBLOCK_SIZE, MEM_TYPE_NON_LISP); |
| 2043 | b->next_free = &b->first_data; | 2040 | b->next_free = &b->first_data; |
| 2044 | b->first_data.string = NULL; | 2041 | b->first_data.string = NULL; |
| 2045 | b->next = NULL; | 2042 | b->next = NULL; |
| @@ -2619,10 +2616,8 @@ make_float (double float_value) | |||
| 2619 | { | 2616 | { |
| 2620 | if (float_block_index == FLOAT_BLOCK_SIZE) | 2617 | if (float_block_index == FLOAT_BLOCK_SIZE) |
| 2621 | { | 2618 | { |
| 2622 | register struct float_block *new; | 2619 | struct float_block *new |
| 2623 | 2620 | = lisp_align_malloc (sizeof *new, MEM_TYPE_FLOAT); | |
| 2624 | new = (struct float_block *) lisp_align_malloc (sizeof *new, | ||
| 2625 | MEM_TYPE_FLOAT); | ||
| 2626 | new->next = float_block; | 2621 | new->next = float_block; |
| 2627 | memset (new->gcmarkbits, 0, sizeof new->gcmarkbits); | 2622 | memset (new->gcmarkbits, 0, sizeof new->gcmarkbits); |
| 2628 | float_block = new; | 2623 | float_block = new; |
| @@ -2738,9 +2733,8 @@ DEFUN ("cons", Fcons, Scons, 2, 2, 0, | |||
| 2738 | { | 2733 | { |
| 2739 | if (cons_block_index == CONS_BLOCK_SIZE) | 2734 | if (cons_block_index == CONS_BLOCK_SIZE) |
| 2740 | { | 2735 | { |
| 2741 | register struct cons_block *new; | 2736 | struct cons_block *new |
| 2742 | new = (struct cons_block *) lisp_align_malloc (sizeof *new, | 2737 | = lisp_align_malloc (sizeof *new, MEM_TYPE_CONS); |
| 2743 | MEM_TYPE_CONS); | ||
| 2744 | memset (new->gcmarkbits, 0, sizeof new->gcmarkbits); | 2738 | memset (new->gcmarkbits, 0, sizeof new->gcmarkbits); |
| 2745 | new->next = cons_block; | 2739 | new->next = cons_block; |
| 2746 | cons_block = new; | 2740 | cons_block = new; |
| @@ -2972,7 +2966,7 @@ static struct Lisp_Vector *zero_vector; | |||
| 2972 | static struct vector_block * | 2966 | static struct vector_block * |
| 2973 | allocate_vector_block (void) | 2967 | allocate_vector_block (void) |
| 2974 | { | 2968 | { |
| 2975 | struct vector_block *block = xmalloc (sizeof (struct vector_block)); | 2969 | struct vector_block *block = xmalloc (sizeof *block); |
| 2976 | 2970 | ||
| 2977 | #if GC_MARK_STACK && !defined GC_MALLOC_CHECK | 2971 | #if GC_MARK_STACK && !defined GC_MALLOC_CHECK |
| 2978 | mem_insert (block->data, block->data + VECTOR_BLOCK_BYTES, | 2972 | mem_insert (block->data, block->data + VECTOR_BLOCK_BYTES, |
| @@ -3198,7 +3192,7 @@ allocate_vectorlike (ptrdiff_t len) | |||
| 3198 | p = allocate_vector_from_block (vroundup (nbytes)); | 3192 | p = allocate_vector_from_block (vroundup (nbytes)); |
| 3199 | else | 3193 | else |
| 3200 | { | 3194 | { |
| 3201 | p = (struct Lisp_Vector *) lisp_malloc (nbytes, MEM_TYPE_VECTORLIKE); | 3195 | p = lisp_malloc (nbytes, MEM_TYPE_VECTORLIKE); |
| 3202 | p->header.next.vector = large_vectors; | 3196 | p->header.next.vector = large_vectors; |
| 3203 | large_vectors = p; | 3197 | large_vectors = p; |
| 3204 | } | 3198 | } |
| @@ -3253,7 +3247,7 @@ allocate_pseudovector (int memlen, int lisplen, int tag) | |||
| 3253 | struct buffer * | 3247 | struct buffer * |
| 3254 | allocate_buffer (void) | 3248 | allocate_buffer (void) |
| 3255 | { | 3249 | { |
| 3256 | struct buffer *b = lisp_malloc (sizeof (struct buffer), MEM_TYPE_BUFFER); | 3250 | struct buffer *b = lisp_malloc (sizeof *b, MEM_TYPE_BUFFER); |
| 3257 | 3251 | ||
| 3258 | XSETPVECTYPESIZE (b, PVEC_BUFFER, (offsetof (struct buffer, own_text) | 3252 | XSETPVECTYPESIZE (b, PVEC_BUFFER, (offsetof (struct buffer, own_text) |
| 3259 | - header_size) / word_size); | 3253 | - header_size) / word_size); |
| @@ -3487,9 +3481,8 @@ Its value and function definition are void, and its property list is nil. */) | |||
| 3487 | { | 3481 | { |
| 3488 | if (symbol_block_index == SYMBOL_BLOCK_SIZE) | 3482 | if (symbol_block_index == SYMBOL_BLOCK_SIZE) |
| 3489 | { | 3483 | { |
| 3490 | struct symbol_block *new; | 3484 | struct symbol_block *new |
| 3491 | new = (struct symbol_block *) lisp_malloc (sizeof *new, | 3485 | = lisp_malloc (sizeof *new, MEM_TYPE_SYMBOL); |
| 3492 | MEM_TYPE_SYMBOL); | ||
| 3493 | new->next = symbol_block; | 3486 | new->next = symbol_block; |
| 3494 | symbol_block = new; | 3487 | symbol_block = new; |
| 3495 | symbol_block_index = 0; | 3488 | symbol_block_index = 0; |
| @@ -3580,9 +3573,7 @@ allocate_misc (void) | |||
| 3580 | { | 3573 | { |
| 3581 | if (marker_block_index == MARKER_BLOCK_SIZE) | 3574 | if (marker_block_index == MARKER_BLOCK_SIZE) |
| 3582 | { | 3575 | { |
| 3583 | struct marker_block *new; | 3576 | struct marker_block *new = lisp_malloc (sizeof *new, MEM_TYPE_MISC); |
| 3584 | new = (struct marker_block *) lisp_malloc (sizeof *new, | ||
| 3585 | MEM_TYPE_MISC); | ||
| 3586 | new->next = marker_block; | 3577 | new->next = marker_block; |
| 3587 | marker_block = new; | 3578 | marker_block = new; |
| 3588 | marker_block_index = 0; | 3579 | marker_block_index = 0; |
| @@ -3775,25 +3766,25 @@ refill_memory_reserve (void) | |||
| 3775 | { | 3766 | { |
| 3776 | #ifndef SYSTEM_MALLOC | 3767 | #ifndef SYSTEM_MALLOC |
| 3777 | if (spare_memory[0] == 0) | 3768 | if (spare_memory[0] == 0) |
| 3778 | spare_memory[0] = (char *) malloc (SPARE_MEMORY); | 3769 | spare_memory[0] = malloc (SPARE_MEMORY); |
| 3779 | if (spare_memory[1] == 0) | 3770 | if (spare_memory[1] == 0) |
| 3780 | spare_memory[1] = (char *) lisp_align_malloc (sizeof (struct cons_block), | 3771 | spare_memory[1] = lisp_align_malloc (sizeof (struct cons_block), |
| 3781 | MEM_TYPE_CONS); | 3772 | MEM_TYPE_CONS); |
| 3782 | if (spare_memory[2] == 0) | 3773 | if (spare_memory[2] == 0) |
| 3783 | spare_memory[2] = (char *) lisp_align_malloc (sizeof (struct cons_block), | 3774 | spare_memory[2] = lisp_align_malloc (sizeof (struct cons_block), |
| 3784 | MEM_TYPE_CONS); | 3775 | MEM_TYPE_CONS); |
| 3785 | if (spare_memory[3] == 0) | 3776 | if (spare_memory[3] == 0) |
| 3786 | spare_memory[3] = (char *) lisp_align_malloc (sizeof (struct cons_block), | 3777 | spare_memory[3] = lisp_align_malloc (sizeof (struct cons_block), |
| 3787 | MEM_TYPE_CONS); | 3778 | MEM_TYPE_CONS); |
| 3788 | if (spare_memory[4] == 0) | 3779 | if (spare_memory[4] == 0) |
| 3789 | spare_memory[4] = (char *) lisp_align_malloc (sizeof (struct cons_block), | 3780 | spare_memory[4] = lisp_align_malloc (sizeof (struct cons_block), |
| 3790 | MEM_TYPE_CONS); | 3781 | MEM_TYPE_CONS); |
| 3791 | if (spare_memory[5] == 0) | 3782 | if (spare_memory[5] == 0) |
| 3792 | spare_memory[5] = (char *) lisp_malloc (sizeof (struct string_block), | 3783 | spare_memory[5] = lisp_malloc (sizeof (struct string_block), |
| 3793 | MEM_TYPE_STRING); | 3784 | MEM_TYPE_STRING); |
| 3794 | if (spare_memory[6] == 0) | 3785 | if (spare_memory[6] == 0) |
| 3795 | spare_memory[6] = (char *) lisp_malloc (sizeof (struct string_block), | 3786 | spare_memory[6] = lisp_malloc (sizeof (struct string_block), |
| 3796 | MEM_TYPE_STRING); | 3787 | MEM_TYPE_STRING); |
| 3797 | if (spare_memory[0] && spare_memory[1] && spare_memory[5]) | 3788 | if (spare_memory[0] && spare_memory[1] && spare_memory[5]) |
| 3798 | Vmemory_full = Qnil; | 3789 | Vmemory_full = Qnil; |
| 3799 | #endif | 3790 | #endif |
| @@ -3893,7 +3884,7 @@ mem_insert (void *start, void *end, enum mem_type type) | |||
| 3893 | 3884 | ||
| 3894 | /* Create a new node. */ | 3885 | /* Create a new node. */ |
| 3895 | #ifdef GC_MALLOC_CHECK | 3886 | #ifdef GC_MALLOC_CHECK |
| 3896 | x = (struct mem_node *) _malloc_internal (sizeof *x); | 3887 | x = _malloc_internal (sizeof *x); |
| 3897 | if (x == NULL) | 3888 | if (x == NULL) |
| 3898 | abort (); | 3889 | abort (); |
| 3899 | #else | 3890 | #else |
| @@ -5441,7 +5432,7 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5441 | { | 5432 | { |
| 5442 | if (stack_copy_size < stack_size) | 5433 | if (stack_copy_size < stack_size) |
| 5443 | { | 5434 | { |
| 5444 | stack_copy = (char *) xrealloc (stack_copy, stack_size); | 5435 | stack_copy = xrealloc (stack_copy, stack_size); |
| 5445 | stack_copy_size = stack_size; | 5436 | stack_copy_size = stack_size; |
| 5446 | } | 5437 | } |
| 5447 | memcpy (stack_copy, stack, stack_size); | 5438 | memcpy (stack_copy, stack, stack_size); |
diff --git a/src/bidi.c b/src/bidi.c index 80986e5b671..0fa1cc2b0e2 100644 --- a/src/bidi.c +++ b/src/bidi.c | |||
| @@ -361,8 +361,7 @@ bidi_cache_shrink (void) | |||
| 361 | { | 361 | { |
| 362 | if (bidi_cache_size > BIDI_CACHE_CHUNK) | 362 | if (bidi_cache_size > BIDI_CACHE_CHUNK) |
| 363 | { | 363 | { |
| 364 | bidi_cache | 364 | bidi_cache = xrealloc (bidi_cache, BIDI_CACHE_CHUNK * elsz); |
| 365 | = (struct bidi_it *) xrealloc (bidi_cache, BIDI_CACHE_CHUNK * elsz); | ||
| 366 | bidi_cache_size = BIDI_CACHE_CHUNK; | 365 | bidi_cache_size = BIDI_CACHE_CHUNK; |
| 367 | } | 366 | } |
| 368 | bidi_cache_reset (); | 367 | bidi_cache_reset (); |
diff --git a/src/buffer.c b/src/buffer.c index e1c33f4c711..838932db4df 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -2793,11 +2793,11 @@ mouse_face_overlay_overlaps (Lisp_Object overlay) | |||
| 2793 | Lisp_Object *v, tem; | 2793 | Lisp_Object *v, tem; |
| 2794 | 2794 | ||
| 2795 | size = 10; | 2795 | size = 10; |
| 2796 | v = (Lisp_Object *) alloca (size * sizeof *v); | 2796 | v = alloca (size * sizeof *v); |
| 2797 | n = overlays_in (start, end, 0, &v, &size, NULL, NULL); | 2797 | n = overlays_in (start, end, 0, &v, &size, NULL, NULL); |
| 2798 | if (n > size) | 2798 | if (n > size) |
| 2799 | { | 2799 | { |
| 2800 | v = (Lisp_Object *) alloca (n * sizeof *v); | 2800 | v = alloca (n * sizeof *v); |
| 2801 | overlays_in (start, end, 0, &v, &n, NULL, NULL); | 2801 | overlays_in (start, end, 0, &v, &n, NULL, NULL); |
| 2802 | } | 2802 | } |
| 2803 | 2803 | ||
| @@ -2885,8 +2885,7 @@ ptrdiff_t | |||
| 2885 | sort_overlays (Lisp_Object *overlay_vec, ptrdiff_t noverlays, struct window *w) | 2885 | sort_overlays (Lisp_Object *overlay_vec, ptrdiff_t noverlays, struct window *w) |
| 2886 | { | 2886 | { |
| 2887 | ptrdiff_t i, j; | 2887 | ptrdiff_t i, j; |
| 2888 | struct sortvec *sortvec; | 2888 | struct sortvec *sortvec = alloca (noverlays * sizeof *sortvec); |
| 2889 | sortvec = (struct sortvec *) alloca (noverlays * sizeof (struct sortvec)); | ||
| 2890 | 2889 | ||
| 2891 | /* Put the valid and relevant overlays into sortvec. */ | 2890 | /* Put the valid and relevant overlays into sortvec. */ |
| 2892 | 2891 | ||
| @@ -3893,7 +3892,7 @@ DEFUN ("overlays-at", Foverlays_at, Soverlays_at, 1, 1, 0, | |||
| 3893 | 3892 | ||
| 3894 | len = 10; | 3893 | len = 10; |
| 3895 | /* We can't use alloca here because overlays_at can call xrealloc. */ | 3894 | /* We can't use alloca here because overlays_at can call xrealloc. */ |
| 3896 | overlay_vec = xmalloc (len * sizeof (Lisp_Object)); | 3895 | overlay_vec = xmalloc (len * sizeof *overlay_vec); |
| 3897 | 3896 | ||
| 3898 | /* Put all the overlays we want in a vector in overlay_vec. | 3897 | /* Put all the overlays we want in a vector in overlay_vec. |
| 3899 | Store the length in len. */ | 3898 | Store the length in len. */ |
| @@ -3924,7 +3923,7 @@ end of the buffer. */) | |||
| 3924 | CHECK_NUMBER_COERCE_MARKER (end); | 3923 | CHECK_NUMBER_COERCE_MARKER (end); |
| 3925 | 3924 | ||
| 3926 | len = 10; | 3925 | len = 10; |
| 3927 | overlay_vec = xmalloc (len * sizeof (Lisp_Object)); | 3926 | overlay_vec = xmalloc (len * sizeof *overlay_vec); |
| 3928 | 3927 | ||
| 3929 | /* Put all the overlays we want in a vector in overlay_vec. | 3928 | /* Put all the overlays we want in a vector in overlay_vec. |
| 3930 | Store the length in len. */ | 3929 | Store the length in len. */ |
| @@ -3952,7 +3951,7 @@ the value is (point-max). */) | |||
| 3952 | CHECK_NUMBER_COERCE_MARKER (pos); | 3951 | CHECK_NUMBER_COERCE_MARKER (pos); |
| 3953 | 3952 | ||
| 3954 | len = 10; | 3953 | len = 10; |
| 3955 | overlay_vec = xmalloc (len * sizeof (Lisp_Object)); | 3954 | overlay_vec = xmalloc (len * sizeof *overlay_vec); |
| 3956 | 3955 | ||
| 3957 | /* Put all the overlays we want in a vector in overlay_vec. | 3956 | /* Put all the overlays we want in a vector in overlay_vec. |
| 3958 | Store the length in len. | 3957 | Store the length in len. |
| @@ -3996,7 +3995,7 @@ the value is (point-min). */) | |||
| 3996 | return pos; | 3995 | return pos; |
| 3997 | 3996 | ||
| 3998 | len = 10; | 3997 | len = 10; |
| 3999 | overlay_vec = xmalloc (len * sizeof (Lisp_Object)); | 3998 | overlay_vec = xmalloc (len * sizeof *overlay_vec); |
| 4000 | 3999 | ||
| 4001 | /* Put all the overlays we want in a vector in overlay_vec. | 4000 | /* Put all the overlays we want in a vector in overlay_vec. |
| 4002 | Store the length in len. | 4001 | Store the length in len. |
| @@ -4251,7 +4250,7 @@ report_overlay_modification (Lisp_Object start, Lisp_Object end, int after, | |||
| 4251 | First copy the vector contents, in case some of these hooks | 4250 | First copy the vector contents, in case some of these hooks |
| 4252 | do subsequent modification of the buffer. */ | 4251 | do subsequent modification of the buffer. */ |
| 4253 | ptrdiff_t size = last_overlay_modification_hooks_used; | 4252 | ptrdiff_t size = last_overlay_modification_hooks_used; |
| 4254 | Lisp_Object *copy = (Lisp_Object *) alloca (size * sizeof (Lisp_Object)); | 4253 | Lisp_Object *copy = alloca (size * sizeof *copy); |
| 4255 | ptrdiff_t i; | 4254 | ptrdiff_t i; |
| 4256 | 4255 | ||
| 4257 | memcpy (copy, XVECTOR (last_overlay_modification_hooks)->contents, | 4256 | memcpy (copy, XVECTOR (last_overlay_modification_hooks)->contents, |
| @@ -4873,7 +4872,7 @@ init_buffer_once (void) | |||
| 4873 | /* If you add, remove, or reorder Lisp_Objects in a struct buffer, make | 4872 | /* If you add, remove, or reorder Lisp_Objects in a struct buffer, make |
| 4874 | sure that this is still correct. Otherwise, mark_vectorlike may not | 4873 | sure that this is still correct. Otherwise, mark_vectorlike may not |
| 4875 | trace all Lisp_Objects in buffer_defaults and buffer_local_symbols. */ | 4874 | trace all Lisp_Objects in buffer_defaults and buffer_local_symbols. */ |
| 4876 | const int pvecsize | 4875 | const int pvecsize |
| 4877 | = (offsetof (struct buffer, own_text) - sizeof (struct vectorlike_header)) | 4876 | = (offsetof (struct buffer, own_text) - sizeof (struct vectorlike_header)) |
| 4878 | / sizeof (Lisp_Object); | 4877 | / sizeof (Lisp_Object); |
| 4879 | 4878 | ||
| @@ -5089,7 +5088,7 @@ init_buffer (void) | |||
| 5089 | if (!(IS_DIRECTORY_SEP (pwd[len - 1]))) | 5088 | if (!(IS_DIRECTORY_SEP (pwd[len - 1]))) |
| 5090 | { | 5089 | { |
| 5091 | /* Grow buffer to add directory separator and '\0'. */ | 5090 | /* Grow buffer to add directory separator and '\0'. */ |
| 5092 | pwd = (char *) realloc (pwd, len + 2); | 5091 | pwd = realloc (pwd, len + 2); |
| 5093 | if (!pwd) | 5092 | if (!pwd) |
| 5094 | fatal ("`get_current_dir_name' failed: %s\n", strerror (errno)); | 5093 | fatal ("`get_current_dir_name' failed: %s\n", strerror (errno)); |
| 5095 | pwd[len] = DIRECTORY_SEP; | 5094 | pwd[len] = DIRECTORY_SEP; |
diff --git a/src/buffer.h b/src/buffer.h index b58c5c165e1..0615f85bfe6 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -918,13 +918,13 @@ extern void mmap_set_vars (int); | |||
| 918 | #define GET_OVERLAYS_AT(posn, overlays, noverlays, nextp, chrq) \ | 918 | #define GET_OVERLAYS_AT(posn, overlays, noverlays, nextp, chrq) \ |
| 919 | do { \ | 919 | do { \ |
| 920 | ptrdiff_t maxlen = 40; \ | 920 | ptrdiff_t maxlen = 40; \ |
| 921 | overlays = (Lisp_Object *) alloca (maxlen * sizeof (Lisp_Object)); \ | 921 | overlays = alloca (maxlen * sizeof *overlays); \ |
| 922 | noverlays = overlays_at (posn, 0, &overlays, &maxlen, \ | 922 | noverlays = overlays_at (posn, 0, &overlays, &maxlen, \ |
| 923 | nextp, NULL, chrq); \ | 923 | nextp, NULL, chrq); \ |
| 924 | if (noverlays > maxlen) \ | 924 | if (noverlays > maxlen) \ |
| 925 | { \ | 925 | { \ |
| 926 | maxlen = noverlays; \ | 926 | maxlen = noverlays; \ |
| 927 | overlays = (Lisp_Object *) alloca (maxlen * sizeof (Lisp_Object)); \ | 927 | overlays = alloca (maxlen * sizeof *overlays); \ |
| 928 | noverlays = overlays_at (posn, 0, &overlays, &maxlen, \ | 928 | noverlays = overlays_at (posn, 0, &overlays, &maxlen, \ |
| 929 | nextp, NULL, chrq); \ | 929 | nextp, NULL, chrq); \ |
| 930 | } \ | 930 | } \ |
diff --git a/src/bytecode.c b/src/bytecode.c index 08a02ea921d..e1363d390e8 100644 --- a/src/bytecode.c +++ b/src/bytecode.c | |||
| @@ -488,8 +488,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 488 | stack.constants = vector; | 488 | stack.constants = vector; |
| 489 | if (MAX_ALLOCA / sizeof (Lisp_Object) <= XFASTINT (maxdepth)) | 489 | if (MAX_ALLOCA / sizeof (Lisp_Object) <= XFASTINT (maxdepth)) |
| 490 | memory_full (SIZE_MAX); | 490 | memory_full (SIZE_MAX); |
| 491 | top = (Lisp_Object *) alloca ((XFASTINT (maxdepth) + 1) | 491 | top = alloca ((XFASTINT (maxdepth) + 1) * sizeof *top); |
| 492 | * sizeof (Lisp_Object)); | ||
| 493 | #if BYTE_MAINTAIN_TOP | 492 | #if BYTE_MAINTAIN_TOP |
| 494 | stack.bottom = top + 1; | 493 | stack.bottom = top + 1; |
| 495 | stack.top = NULL; | 494 | stack.top = NULL; |
diff --git a/src/callint.c b/src/callint.c index e5ff99714c0..1a99ca2731c 100644 --- a/src/callint.c +++ b/src/callint.c | |||
| @@ -331,7 +331,7 @@ invoke it. If KEYS is omitted or nil, the return value of | |||
| 331 | { | 331 | { |
| 332 | /* Make a copy of string so that if a GC relocates specs, | 332 | /* Make a copy of string so that if a GC relocates specs, |
| 333 | `string' will still be valid. */ | 333 | `string' will still be valid. */ |
| 334 | string = (char *) alloca (SBYTES (specs) + 1); | 334 | string = alloca (SBYTES (specs) + 1); |
| 335 | memcpy (string, SSDATA (specs), SBYTES (specs) + 1); | 335 | memcpy (string, SSDATA (specs), SBYTES (specs) + 1); |
| 336 | } | 336 | } |
| 337 | else | 337 | else |
| @@ -469,9 +469,9 @@ invoke it. If KEYS is omitted or nil, the return value of | |||
| 469 | < nargs) | 469 | < nargs) |
| 470 | memory_full (SIZE_MAX); | 470 | memory_full (SIZE_MAX); |
| 471 | 471 | ||
| 472 | args = (Lisp_Object *) alloca (nargs * sizeof (Lisp_Object)); | 472 | args = alloca (nargs * sizeof *args); |
| 473 | visargs = (Lisp_Object *) alloca (nargs * sizeof (Lisp_Object)); | 473 | visargs = alloca (nargs * sizeof *visargs); |
| 474 | varies = (signed char *) alloca (nargs); | 474 | varies = alloca (nargs * sizeof *varies); |
| 475 | 475 | ||
| 476 | for (i = 0; i < nargs; i++) | 476 | for (i = 0; i < nargs; i++) |
| 477 | { | 477 | { |
diff --git a/src/callproc.c b/src/callproc.c index 0418e4e8cd5..39fcb99c4b5 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -1174,7 +1174,7 @@ child_setup (int in, int out, int err, register char **new_argv, int set_pgrp, L | |||
| 1174 | on that. */ | 1174 | on that. */ |
| 1175 | pwd_var = xmalloc (i + 6); | 1175 | pwd_var = xmalloc (i + 6); |
| 1176 | #else | 1176 | #else |
| 1177 | pwd_var = (char *) alloca (i + 6); | 1177 | pwd_var = alloca (i + 6); |
| 1178 | #endif | 1178 | #endif |
| 1179 | temp = pwd_var + 4; | 1179 | temp = pwd_var + 4; |
| 1180 | memcpy (pwd_var, "PWD=", 4); | 1180 | memcpy (pwd_var, "PWD=", 4); |
| @@ -1242,7 +1242,7 @@ child_setup (int in, int out, int err, register char **new_argv, int set_pgrp, L | |||
| 1242 | } | 1242 | } |
| 1243 | 1243 | ||
| 1244 | /* new_length + 2 to include PWD and terminating 0. */ | 1244 | /* new_length + 2 to include PWD and terminating 0. */ |
| 1245 | env = new_env = (char **) alloca ((new_length + 2) * sizeof (char *)); | 1245 | env = new_env = alloca ((new_length + 2) * sizeof *env); |
| 1246 | /* If we have a PWD envvar, pass one down, | 1246 | /* If we have a PWD envvar, pass one down, |
| 1247 | but with corrected value. */ | 1247 | but with corrected value. */ |
| 1248 | if (egetenv ("PWD")) | 1248 | if (egetenv ("PWD")) |
| @@ -1250,7 +1250,7 @@ child_setup (int in, int out, int err, register char **new_argv, int set_pgrp, L | |||
| 1250 | 1250 | ||
| 1251 | if (STRINGP (display)) | 1251 | if (STRINGP (display)) |
| 1252 | { | 1252 | { |
| 1253 | char *vdata = (char *) alloca (sizeof "DISPLAY=" + SBYTES (display)); | 1253 | char *vdata = alloca (sizeof "DISPLAY=" + SBYTES (display)); |
| 1254 | strcpy (vdata, "DISPLAY="); | 1254 | strcpy (vdata, "DISPLAY="); |
| 1255 | strcat (vdata, SSDATA (display)); | 1255 | strcat (vdata, SSDATA (display)); |
| 1256 | new_env = add_env (env, new_env, vdata); | 1256 | new_env = add_env (env, new_env, vdata); |
diff --git a/src/charset.c b/src/charset.c index a0ed9673e98..4c47ba45fb6 100644 --- a/src/charset.c +++ b/src/charset.c | |||
| @@ -294,7 +294,7 @@ load_charset_map (struct charset *charset, struct charset_map_entries *entries, | |||
| 294 | else | 294 | else |
| 295 | { | 295 | { |
| 296 | if (! temp_charset_work) | 296 | if (! temp_charset_work) |
| 297 | temp_charset_work = xmalloc (sizeof (*temp_charset_work)); | 297 | temp_charset_work = xmalloc (sizeof *temp_charset_work); |
| 298 | if (control_flag == 1) | 298 | if (control_flag == 1) |
| 299 | { | 299 | { |
| 300 | memset (temp_charset_work->table.decoder, -1, | 300 | memset (temp_charset_work->table.decoder, -1, |
diff --git a/src/coding.c b/src/coding.c index 891fea09abf..4b2a9740121 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -1145,8 +1145,8 @@ coding_alloc_by_realloc (struct coding_system *coding, ptrdiff_t bytes) | |||
| 1145 | { | 1145 | { |
| 1146 | if (STRING_BYTES_BOUND - coding->dst_bytes < bytes) | 1146 | if (STRING_BYTES_BOUND - coding->dst_bytes < bytes) |
| 1147 | string_overflow (); | 1147 | string_overflow (); |
| 1148 | coding->destination = (unsigned char *) xrealloc (coding->destination, | 1148 | coding->destination = xrealloc (coding->destination, |
| 1149 | coding->dst_bytes + bytes); | 1149 | coding->dst_bytes + bytes); |
| 1150 | coding->dst_bytes += bytes; | 1150 | coding->dst_bytes += bytes; |
| 1151 | } | 1151 | } |
| 1152 | 1152 | ||
| @@ -7010,7 +7010,7 @@ produce_charset (struct coding_system *coding, int *charbuf, ptrdiff_t pos) | |||
| 7010 | coding->charbuf = NULL; \ | 7010 | coding->charbuf = NULL; \ |
| 7011 | while (size > 1024) \ | 7011 | while (size > 1024) \ |
| 7012 | { \ | 7012 | { \ |
| 7013 | coding->charbuf = (int *) alloca (sizeof (int) * size); \ | 7013 | coding->charbuf = alloca (sizeof (int) * size); \ |
| 7014 | if (coding->charbuf) \ | 7014 | if (coding->charbuf) \ |
| 7015 | break; \ | 7015 | break; \ |
| 7016 | size >>= 1; \ | 7016 | size >>= 1; \ |
| @@ -9568,7 +9568,7 @@ make_subsidiaries (Lisp_Object base) | |||
| 9568 | { | 9568 | { |
| 9569 | Lisp_Object subsidiaries; | 9569 | Lisp_Object subsidiaries; |
| 9570 | ptrdiff_t base_name_len = SBYTES (SYMBOL_NAME (base)); | 9570 | ptrdiff_t base_name_len = SBYTES (SYMBOL_NAME (base)); |
| 9571 | char *buf = (char *) alloca (base_name_len + 6); | 9571 | char *buf = alloca (base_name_len + 6); |
| 9572 | int i; | 9572 | int i; |
| 9573 | 9573 | ||
| 9574 | memcpy (buf, SDATA (SYMBOL_NAME (base)), base_name_len); | 9574 | memcpy (buf, SDATA (SYMBOL_NAME (base)), base_name_len); |
diff --git a/src/composite.c b/src/composite.c index 464b55202d7..87fad6fa18f 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 = xmalloc (sizeof (struct composition)); | 329 | cmp = xmalloc (sizeof *cmp); |
| 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/data.c b/src/data.c index fe7b9420344..faa87d0013f 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -1463,8 +1463,7 @@ union Lisp_Val_Fwd | |||
| 1463 | static struct Lisp_Buffer_Local_Value * | 1463 | static struct Lisp_Buffer_Local_Value * |
| 1464 | make_blv (struct Lisp_Symbol *sym, int forwarded, union Lisp_Val_Fwd valcontents) | 1464 | make_blv (struct Lisp_Symbol *sym, int forwarded, union Lisp_Val_Fwd valcontents) |
| 1465 | { | 1465 | { |
| 1466 | struct Lisp_Buffer_Local_Value *blv | 1466 | struct Lisp_Buffer_Local_Value *blv = xmalloc (sizeof *blv); |
| 1467 | = xmalloc (sizeof (struct Lisp_Buffer_Local_Value)); | ||
| 1468 | Lisp_Object symbol; | 1467 | Lisp_Object symbol; |
| 1469 | Lisp_Object tem; | 1468 | Lisp_Object tem; |
| 1470 | 1469 | ||
diff --git a/src/dispnew.c b/src/dispnew.c index 17bd2e828fa..5c6ea0123be 100644 --- a/src/dispnew.c +++ b/src/dispnew.c | |||
| @@ -2023,9 +2023,7 @@ static struct glyph_matrix * | |||
| 2023 | save_current_matrix (struct frame *f) | 2023 | save_current_matrix (struct frame *f) |
| 2024 | { | 2024 | { |
| 2025 | int i; | 2025 | int i; |
| 2026 | struct glyph_matrix *saved; | 2026 | struct glyph_matrix *saved = xzalloc (sizeof *saved); |
| 2027 | |||
| 2028 | saved = xzalloc (sizeof *saved); | ||
| 2029 | saved->nrows = f->current_matrix->nrows; | 2027 | saved->nrows = f->current_matrix->nrows; |
| 2030 | saved->rows = xzalloc (saved->nrows * sizeof *saved->rows); | 2028 | saved->rows = xzalloc (saved->nrows * sizeof *saved->rows); |
| 2031 | 2029 | ||
| @@ -2243,16 +2241,8 @@ adjust_frame_glyphs_for_window_redisplay (struct frame *f) | |||
| 2243 | static void | 2241 | static void |
| 2244 | adjust_frame_message_buffer (struct frame *f) | 2242 | adjust_frame_message_buffer (struct frame *f) |
| 2245 | { | 2243 | { |
| 2246 | ptrdiff_t size = FRAME_MESSAGE_BUF_SIZE (f) + 1; | 2244 | FRAME_MESSAGE_BUF (f) = xrealloc (FRAME_MESSAGE_BUF (f), |
| 2247 | 2245 | FRAME_MESSAGE_BUF_SIZE (f) + 1); | |
| 2248 | if (FRAME_MESSAGE_BUF (f)) | ||
| 2249 | { | ||
| 2250 | char *buffer = FRAME_MESSAGE_BUF (f); | ||
| 2251 | char *new_buffer = (char *) xrealloc (buffer, size); | ||
| 2252 | FRAME_MESSAGE_BUF (f) = new_buffer; | ||
| 2253 | } | ||
| 2254 | else | ||
| 2255 | FRAME_MESSAGE_BUF (f) = xmalloc (size); | ||
| 2256 | } | 2246 | } |
| 2257 | 2247 | ||
| 2258 | 2248 | ||
| @@ -2261,9 +2251,8 @@ adjust_frame_message_buffer (struct frame *f) | |||
| 2261 | static void | 2251 | static void |
| 2262 | adjust_decode_mode_spec_buffer (struct frame *f) | 2252 | adjust_decode_mode_spec_buffer (struct frame *f) |
| 2263 | { | 2253 | { |
| 2264 | f->decode_mode_spec_buffer | 2254 | f->decode_mode_spec_buffer = xrealloc (f->decode_mode_spec_buffer, |
| 2265 | = (char *) xrealloc (f->decode_mode_spec_buffer, | 2255 | FRAME_MESSAGE_BUF_SIZE (f) + 1); |
| 2266 | FRAME_MESSAGE_BUF_SIZE (f) + 1); | ||
| 2267 | } | 2256 | } |
| 2268 | 2257 | ||
| 2269 | 2258 | ||
| @@ -2810,7 +2799,7 @@ mirrored_line_dance (struct glyph_matrix *matrix, int unchanged_at_top, int nlin | |||
| 2810 | int i; | 2799 | int i; |
| 2811 | 2800 | ||
| 2812 | /* Make a copy of the original rows. */ | 2801 | /* Make a copy of the original rows. */ |
| 2813 | old_rows = (struct glyph_row *) alloca (nlines * sizeof *old_rows); | 2802 | old_rows = alloca (nlines * sizeof *old_rows); |
| 2814 | memcpy (old_rows, new_rows, nlines * sizeof *old_rows); | 2803 | memcpy (old_rows, new_rows, nlines * sizeof *old_rows); |
| 2815 | 2804 | ||
| 2816 | /* Assign new rows, maybe clear lines. */ | 2805 | /* Assign new rows, maybe clear lines. */ |
| @@ -2928,7 +2917,7 @@ mirror_line_dance (struct window *w, int unchanged_at_top, int nlines, int *copy | |||
| 2928 | struct glyph_row *old_rows; | 2917 | struct glyph_row *old_rows; |
| 2929 | 2918 | ||
| 2930 | /* Make a copy of the original rows of matrix m. */ | 2919 | /* Make a copy of the original rows of matrix m. */ |
| 2931 | old_rows = (struct glyph_row *) alloca (m->nrows * sizeof *old_rows); | 2920 | old_rows = alloca (m->nrows * sizeof *old_rows); |
| 2932 | memcpy (old_rows, m->rows, m->nrows * sizeof *old_rows); | 2921 | memcpy (old_rows, m->rows, m->nrows * sizeof *old_rows); |
| 2933 | 2922 | ||
| 2934 | for (i = 0; i < nlines; ++i) | 2923 | for (i = 0; i < nlines; ++i) |
| @@ -4845,10 +4834,10 @@ scrolling (struct frame *frame) | |||
| 4845 | int unchanged_at_top, unchanged_at_bottom; | 4834 | int unchanged_at_top, unchanged_at_bottom; |
| 4846 | int window_size; | 4835 | int window_size; |
| 4847 | int changed_lines; | 4836 | int changed_lines; |
| 4848 | int *old_hash = (int *) alloca (FRAME_LINES (frame) * sizeof (int)); | 4837 | int *old_hash = alloca (FRAME_LINES (frame) * sizeof (int)); |
| 4849 | int *new_hash = (int *) alloca (FRAME_LINES (frame) * sizeof (int)); | 4838 | int *new_hash = alloca (FRAME_LINES (frame) * sizeof (int)); |
| 4850 | int *draw_cost = (int *) alloca (FRAME_LINES (frame) * sizeof (int)); | 4839 | int *draw_cost = alloca (FRAME_LINES (frame) * sizeof (int)); |
| 4851 | int *old_draw_cost = (int *) alloca (FRAME_LINES (frame) * sizeof (int)); | 4840 | int *old_draw_cost = alloca (FRAME_LINES (frame) * sizeof (int)); |
| 4852 | register int i; | 4841 | register int i; |
| 4853 | int free_at_end_vpos = FRAME_LINES (frame); | 4842 | int free_at_end_vpos = FRAME_LINES (frame); |
| 4854 | struct glyph_matrix *current_matrix = frame->current_matrix; | 4843 | struct glyph_matrix *current_matrix = frame->current_matrix; |
| @@ -577,14 +577,13 @@ the same file name is found in the `doc-directory'. */) | |||
| 577 | (0) | 577 | (0) |
| 578 | #endif /* CANNOT_DUMP */ | 578 | #endif /* CANNOT_DUMP */ |
| 579 | { | 579 | { |
| 580 | name = (char *) alloca (SCHARS (filename) + 14); | 580 | name = alloca (SCHARS (filename) + 14); |
| 581 | strcpy (name, "../etc/"); | 581 | strcpy (name, "../etc/"); |
| 582 | } | 582 | } |
| 583 | else | 583 | else |
| 584 | { | 584 | { |
| 585 | CHECK_STRING (Vdoc_directory); | 585 | CHECK_STRING (Vdoc_directory); |
| 586 | name = (char *) alloca (SCHARS (filename) | 586 | name = alloca (SCHARS (filename) + SCHARS (Vdoc_directory) + 1); |
| 587 | + SCHARS (Vdoc_directory) + 1); | ||
| 588 | strcpy (name, SSDATA (Vdoc_directory)); | 587 | strcpy (name, SSDATA (Vdoc_directory)); |
| 589 | } | 588 | } |
| 590 | strcat (name, SSDATA (filename)); /*** Add this line ***/ | 589 | strcat (name, SSDATA (filename)); /*** Add this line ***/ |
| @@ -828,7 +827,7 @@ Otherwise, return a new string, without any text properties. */) | |||
| 828 | ptrdiff_t offset = bufp - buf; | 827 | ptrdiff_t offset = bufp - buf; |
| 829 | if (STRING_BYTES_BOUND - 4 < bsize) | 828 | if (STRING_BYTES_BOUND - 4 < bsize) |
| 830 | string_overflow (); | 829 | string_overflow (); |
| 831 | buf = (char *) xrealloc (buf, bsize += 4); | 830 | buf = xrealloc (buf, bsize += 4); |
| 832 | bufp = buf + offset; | 831 | bufp = buf + offset; |
| 833 | memcpy (bufp, "M-x ", 4); | 832 | memcpy (bufp, "M-x ", 4); |
| 834 | bufp += 4; | 833 | bufp += 4; |
| @@ -924,7 +923,7 @@ Otherwise, return a new string, without any text properties. */) | |||
| 924 | ptrdiff_t offset = bufp - buf; | 923 | ptrdiff_t offset = bufp - buf; |
| 925 | if (STRING_BYTES_BOUND - length_byte < bsize) | 924 | if (STRING_BYTES_BOUND - length_byte < bsize) |
| 926 | string_overflow (); | 925 | string_overflow (); |
| 927 | buf = (char *) xrealloc (buf, bsize += length_byte); | 926 | buf = xrealloc (buf, bsize += length_byte); |
| 928 | bufp = buf + offset; | 927 | bufp = buf + offset; |
| 929 | memcpy (bufp, start, length_byte); | 928 | memcpy (bufp, start, length_byte); |
| 930 | bufp += length_byte; | 929 | bufp += length_byte; |
diff --git a/src/editfns.c b/src/editfns.c index 5ca68d4f37a..d4146cefb92 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -397,14 +397,14 @@ get_pos_property (Lisp_Object position, register Lisp_Object prop, Lisp_Object o | |||
| 397 | 397 | ||
| 398 | /* First try with room for 40 overlays. */ | 398 | /* First try with room for 40 overlays. */ |
| 399 | noverlays = 40; | 399 | noverlays = 40; |
| 400 | overlay_vec = (Lisp_Object *) alloca (noverlays * sizeof (Lisp_Object)); | 400 | overlay_vec = alloca (noverlays * sizeof *overlay_vec); |
| 401 | noverlays = overlays_around (posn, overlay_vec, noverlays); | 401 | noverlays = overlays_around (posn, overlay_vec, noverlays); |
| 402 | 402 | ||
| 403 | /* If there are more than 40, | 403 | /* If there are more than 40, |
| 404 | make enough space for all, and try again. */ | 404 | make enough space for all, and try again. */ |
| 405 | if (noverlays > 40) | 405 | if (noverlays > 40) |
| 406 | { | 406 | { |
| 407 | overlay_vec = (Lisp_Object *) alloca (noverlays * sizeof (Lisp_Object)); | 407 | overlay_vec = alloca (noverlays * sizeof *overlay_vec); |
| 408 | noverlays = overlays_around (posn, overlay_vec, noverlays); | 408 | noverlays = overlays_around (posn, overlay_vec, noverlays); |
| 409 | } | 409 | } |
| 410 | noverlays = sort_overlays (overlay_vec, noverlays, NULL); | 410 | noverlays = sort_overlays (overlay_vec, noverlays, NULL); |
| @@ -1330,7 +1330,7 @@ name, or nil if there is no such user. */) | |||
| 1330 | Lisp_Object login; | 1330 | Lisp_Object login; |
| 1331 | 1331 | ||
| 1332 | login = Fuser_login_name (make_number (pw->pw_uid)); | 1332 | login = Fuser_login_name (make_number (pw->pw_uid)); |
| 1333 | r = (char *) alloca (strlen (p) + SCHARS (login) + 1); | 1333 | r = alloca (strlen (p) + SCHARS (login) + 1); |
| 1334 | memcpy (r, p, q - p); | 1334 | memcpy (r, p, q - p); |
| 1335 | r[q - p] = 0; | 1335 | r[q - p] = 0; |
| 1336 | strcat (r, SSDATA (login)); | 1336 | strcat (r, SSDATA (login)); |
| @@ -2154,7 +2154,7 @@ set_time_zone_rule (const char *tzstring) | |||
| 2154 | for (from = environ; *from; from++) | 2154 | for (from = environ; *from; from++) |
| 2155 | continue; | 2155 | continue; |
| 2156 | envptrs = from - environ + 2; | 2156 | envptrs = from - environ + 2; |
| 2157 | newenv = to = xmalloc (envptrs * sizeof (char *) | 2157 | newenv = to = xmalloc (envptrs * sizeof *newenv |
| 2158 | + (tzstring ? strlen (tzstring) + 4 : 0)); | 2158 | + (tzstring ? strlen (tzstring) + 4 : 0)); |
| 2159 | 2159 | ||
| 2160 | /* Add TZSTRING to the end of environ, as a value for TZ. */ | 2160 | /* Add TZSTRING to the end of environ, as a value for TZ. */ |
| @@ -3472,15 +3472,11 @@ usage: (message-box FORMAT-STRING &rest ARGS) */) | |||
| 3472 | } | 3472 | } |
| 3473 | #endif /* HAVE_MENUS */ | 3473 | #endif /* HAVE_MENUS */ |
| 3474 | /* Copy the data so that it won't move when we GC. */ | 3474 | /* Copy the data so that it won't move when we GC. */ |
| 3475 | if (! message_text) | ||
| 3476 | { | ||
| 3477 | message_text = xmalloc (80); | ||
| 3478 | message_length = 80; | ||
| 3479 | } | ||
| 3480 | if (SBYTES (val) > message_length) | 3475 | if (SBYTES (val) > message_length) |
| 3481 | { | 3476 | { |
| 3482 | message_text = (char *) xrealloc (message_text, SBYTES (val)); | 3477 | ptrdiff_t new_length = SBYTES (val) + 80; |
| 3483 | message_length = SBYTES (val); | 3478 | message_text = xrealloc (message_text, new_length); |
| 3479 | message_length = new_length; | ||
| 3484 | } | 3480 | } |
| 3485 | memcpy (message_text, SDATA (val), SBYTES (val)); | 3481 | memcpy (message_text, SDATA (val), SBYTES (val)); |
| 3486 | message2 (message_text, SBYTES (val), | 3482 | message2 (message_text, SBYTES (val), |
diff --git a/src/emacs.c b/src/emacs.c index 6a7e9299b36..bdc92f88e8e 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 = xmalloc (sizeof (char *) * argc); | 1823 | char **new = xmalloc (argc * sizeof *new); |
| 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 d35b71530ac..9da9ec05cae 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 = xmalloc (size * sizeof (struct specbinding)); | 141 | specpdl = xmalloc (size * sizeof *specpdl); |
| 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"). */ |
| @@ -2803,7 +2803,8 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) | |||
| 2803 | { | 2803 | { |
| 2804 | if (XSUBR (fun)->max_args > numargs) | 2804 | if (XSUBR (fun)->max_args > numargs) |
| 2805 | { | 2805 | { |
| 2806 | internal_args = (Lisp_Object *) alloca (XSUBR (fun)->max_args * sizeof (Lisp_Object)); | 2806 | internal_args = alloca (XSUBR (fun)->max_args |
| 2807 | * sizeof *internal_args); | ||
| 2807 | memcpy (internal_args, args + 1, numargs * sizeof (Lisp_Object)); | 2808 | memcpy (internal_args, args + 1, numargs * sizeof (Lisp_Object)); |
| 2808 | for (i = numargs; i < XSUBR (fun)->max_args; i++) | 2809 | for (i = numargs; i < XSUBR (fun)->max_args; i++) |
| 2809 | internal_args[i] = Qnil; | 2810 | internal_args[i] = Qnil; |
diff --git a/src/fileio.c b/src/fileio.c index 69ec7b05392..0f6a1d5f799 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -336,7 +336,7 @@ Given a Unix syntax file name, returns a string ending in slash. */) | |||
| 336 | 336 | ||
| 337 | filename = FILE_SYSTEM_CASE (filename); | 337 | filename = FILE_SYSTEM_CASE (filename); |
| 338 | #ifdef DOS_NT | 338 | #ifdef DOS_NT |
| 339 | beg = (char *) alloca (SBYTES (filename) + 1); | 339 | beg = alloca (SBYTES (filename) + 1); |
| 340 | memcpy (beg, SSDATA (filename), SBYTES (filename) + 1); | 340 | memcpy (beg, SSDATA (filename), SBYTES (filename) + 1); |
| 341 | #else | 341 | #else |
| 342 | beg = SSDATA (filename); | 342 | beg = SSDATA (filename); |
| @@ -510,7 +510,7 @@ For a Unix-syntax file name, just appends a slash. */) | |||
| 510 | error ("Invalid handler in `file-name-handler-alist'"); | 510 | error ("Invalid handler in `file-name-handler-alist'"); |
| 511 | } | 511 | } |
| 512 | 512 | ||
| 513 | buf = (char *) alloca (SBYTES (file) + 10); | 513 | buf = alloca (SBYTES (file) + 10); |
| 514 | file_name_as_directory (buf, SSDATA (file)); | 514 | file_name_as_directory (buf, SSDATA (file)); |
| 515 | return make_specified_string (buf, -1, strlen (buf), | 515 | return make_specified_string (buf, -1, strlen (buf), |
| 516 | STRING_MULTIBYTE (file)); | 516 | STRING_MULTIBYTE (file)); |
| @@ -575,7 +575,7 @@ In Unix-syntax, this function just removes the final slash. */) | |||
| 575 | error ("Invalid handler in `file-name-handler-alist'"); | 575 | error ("Invalid handler in `file-name-handler-alist'"); |
| 576 | } | 576 | } |
| 577 | 577 | ||
| 578 | buf = (char *) alloca (SBYTES (directory) + 20); | 578 | buf = alloca (SBYTES (directory) + 20); |
| 579 | directory_file_name (SSDATA (directory), buf); | 579 | directory_file_name (SSDATA (directory), buf); |
| 580 | return make_specified_string (buf, -1, strlen (buf), | 580 | return make_specified_string (buf, -1, strlen (buf), |
| 581 | STRING_MULTIBYTE (directory)); | 581 | STRING_MULTIBYTE (directory)); |
| @@ -878,7 +878,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 878 | } | 878 | } |
| 879 | 879 | ||
| 880 | /* Make a local copy of nm[] to protect it from GC in DECODE_FILE below. */ | 880 | /* Make a local copy of nm[] to protect it from GC in DECODE_FILE below. */ |
| 881 | nm = (char *) alloca (SBYTES (name) + 1); | 881 | nm = alloca (SBYTES (name) + 1); |
| 882 | memcpy (nm, SSDATA (name), SBYTES (name) + 1); | 882 | memcpy (nm, SSDATA (name), SBYTES (name) + 1); |
| 883 | 883 | ||
| 884 | #ifdef DOS_NT | 884 | #ifdef DOS_NT |
| @@ -1186,7 +1186,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 1186 | #endif | 1186 | #endif |
| 1187 | ) | 1187 | ) |
| 1188 | { | 1188 | { |
| 1189 | char *temp = (char *) alloca (length); | 1189 | char *temp = alloca (length); |
| 1190 | memcpy (temp, newdir, length - 1); | 1190 | memcpy (temp, newdir, length - 1); |
| 1191 | temp[length - 1] = 0; | 1191 | temp[length - 1] = 0; |
| 1192 | newdir = temp; | 1192 | newdir = temp; |
| @@ -1202,10 +1202,10 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 1202 | /* Reserve space for drive specifier and escape prefix, since either | 1202 | /* Reserve space for drive specifier and escape prefix, since either |
| 1203 | or both may need to be inserted. (The Microsoft x86 compiler | 1203 | or both may need to be inserted. (The Microsoft x86 compiler |
| 1204 | produces incorrect code if the following two lines are combined.) */ | 1204 | produces incorrect code if the following two lines are combined.) */ |
| 1205 | target = (char *) alloca (tlen + 4); | 1205 | target = alloca (tlen + 4); |
| 1206 | target += 4; | 1206 | target += 4; |
| 1207 | #else /* not DOS_NT */ | 1207 | #else /* not DOS_NT */ |
| 1208 | target = (char *) alloca (tlen); | 1208 | target = alloca (tlen); |
| 1209 | #endif /* not DOS_NT */ | 1209 | #endif /* not DOS_NT */ |
| 1210 | *target = 0; | 1210 | *target = 0; |
| 1211 | 1211 | ||
| @@ -1415,7 +1415,7 @@ See also the function `substitute-in-file-name'.") | |||
| 1415 | unsigned char *ptr = (unsigned char *) strchr (user, '/'); | 1415 | unsigned char *ptr = (unsigned char *) strchr (user, '/'); |
| 1416 | ptrdiff_t len = ptr ? ptr - user : strlen (user); | 1416 | ptrdiff_t len = ptr ? ptr - user : strlen (user); |
| 1417 | /* Copy the user name into temp storage. */ | 1417 | /* Copy the user name into temp storage. */ |
| 1418 | o = (unsigned char *) alloca (len + 1); | 1418 | o = alloca (len + 1); |
| 1419 | memcpy (o, user, len); | 1419 | memcpy (o, user, len); |
| 1420 | o[len] = 0; | 1420 | o[len] = 0; |
| 1421 | 1421 | ||
| @@ -1443,7 +1443,7 @@ See also the function `substitute-in-file-name'.") | |||
| 1443 | /* Now concatenate the directory and name to new space in the stack frame. */ | 1443 | /* Now concatenate the directory and name to new space in the stack frame. */ |
| 1444 | 1444 | ||
| 1445 | tlen = (newdir ? strlen (newdir) + 1 : 0) + strlen (nm) + 1; | 1445 | tlen = (newdir ? strlen (newdir) + 1 : 0) + strlen (nm) + 1; |
| 1446 | target = (unsigned char *) alloca (tlen); | 1446 | target = alloca (tlen); |
| 1447 | *target = 0; | 1447 | *target = 0; |
| 1448 | 1448 | ||
| 1449 | if (newdir) | 1449 | if (newdir) |
| @@ -1593,7 +1593,7 @@ those `/' is discarded. */) | |||
| 1593 | /* Always work on a copy of the string, in case GC happens during | 1593 | /* Always work on a copy of the string, in case GC happens during |
| 1594 | decode of environment variables, causing the original Lisp_String | 1594 | decode of environment variables, causing the original Lisp_String |
| 1595 | data to be relocated. */ | 1595 | data to be relocated. */ |
| 1596 | nm = (char *) alloca (SBYTES (filename) + 1); | 1596 | nm = alloca (SBYTES (filename) + 1); |
| 1597 | memcpy (nm, SDATA (filename), SBYTES (filename) + 1); | 1597 | memcpy (nm, SDATA (filename), SBYTES (filename) + 1); |
| 1598 | 1598 | ||
| 1599 | #ifdef DOS_NT | 1599 | #ifdef DOS_NT |
| @@ -1645,7 +1645,7 @@ those `/' is discarded. */) | |||
| 1645 | } | 1645 | } |
| 1646 | 1646 | ||
| 1647 | /* Copy out the variable name. */ | 1647 | /* Copy out the variable name. */ |
| 1648 | target = (char *) alloca (s - o + 1); | 1648 | target = alloca (s - o + 1); |
| 1649 | strncpy (target, o, s - o); | 1649 | strncpy (target, o, s - o); |
| 1650 | target[s - o] = 0; | 1650 | target[s - o] = 0; |
| 1651 | #ifdef DOS_NT | 1651 | #ifdef DOS_NT |
| @@ -1676,7 +1676,7 @@ those `/' is discarded. */) | |||
| 1676 | 1676 | ||
| 1677 | /* If substitution required, recopy the string and do it. */ | 1677 | /* If substitution required, recopy the string and do it. */ |
| 1678 | /* Make space in stack frame for the new copy. */ | 1678 | /* Make space in stack frame for the new copy. */ |
| 1679 | xnm = (char *) alloca (SBYTES (filename) + total + 1); | 1679 | xnm = alloca (SBYTES (filename) + total + 1); |
| 1680 | x = xnm; | 1680 | x = xnm; |
| 1681 | 1681 | ||
| 1682 | /* Copy the rest of the name through, replacing $ constructs with values. */ | 1682 | /* Copy the rest of the name through, replacing $ constructs with values. */ |
| @@ -1708,7 +1708,7 @@ those `/' is discarded. */) | |||
| 1708 | } | 1708 | } |
| 1709 | 1709 | ||
| 1710 | /* Copy out the variable name. */ | 1710 | /* Copy out the variable name. */ |
| 1711 | target = (char *) alloca (s - o + 1); | 1711 | target = alloca (s - o + 1); |
| 1712 | strncpy (target, o, s - o); | 1712 | strncpy (target, o, s - o); |
| 1713 | target[s - o] = 0; | 1713 | target[s - o] = 0; |
| 1714 | #ifdef DOS_NT | 1714 | #ifdef DOS_NT |
diff --git a/src/filelock.c b/src/filelock.c index 1497529c6e0..252ee3cfb1d 100644 --- a/src/filelock.c +++ b/src/filelock.c | |||
| @@ -294,7 +294,7 @@ typedef struct | |||
| 294 | trailing period plus one for the digit after it plus one for the | 294 | trailing period plus one for the digit after it plus one for the |
| 295 | null. */ | 295 | null. */ |
| 296 | #define MAKE_LOCK_NAME(lock, file) \ | 296 | #define MAKE_LOCK_NAME(lock, file) \ |
| 297 | (lock = (char *) alloca (SBYTES (file) + 2 + 1 + 1 + 1), \ | 297 | (lock = alloca (SBYTES (file) + 2 + 1 + 1 + 1), \ |
| 298 | fill_in_lock_file_name (lock, (file))) | 298 | fill_in_lock_file_name (lock, (file))) |
| 299 | 299 | ||
| 300 | static void | 300 | static void |
| @@ -4347,7 +4347,7 @@ usage: (make-hash-table &rest KEYWORD-ARGS) */) | |||
| 4347 | 4347 | ||
| 4348 | /* The vector `used' is used to keep track of arguments that | 4348 | /* The vector `used' is used to keep track of arguments that |
| 4349 | have been consumed. */ | 4349 | have been consumed. */ |
| 4350 | used = (char *) alloca (nargs * sizeof *used); | 4350 | used = alloca (nargs * sizeof *used); |
| 4351 | memset (used, 0, nargs * sizeof *used); | 4351 | memset (used, 0, nargs * sizeof *used); |
| 4352 | 4352 | ||
| 4353 | /* See if there's a `:test TEST' among the arguments. */ | 4353 | /* See if there's a `:test TEST' among the arguments. */ |
diff --git a/src/font.c b/src/font.c index 555c76c73c8..4f0f814a583 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -3402,7 +3402,7 @@ register_font_driver (struct font_driver *driver, FRAME_PTR f) | |||
| 3402 | if (EQ (list->driver->type, driver->type)) | 3402 | if (EQ (list->driver->type, driver->type)) |
| 3403 | error ("Duplicated font driver: %s", SDATA (SYMBOL_NAME (driver->type))); | 3403 | error ("Duplicated font driver: %s", SDATA (SYMBOL_NAME (driver->type))); |
| 3404 | 3404 | ||
| 3405 | list = xmalloc (sizeof (struct font_driver_list)); | 3405 | list = xmalloc (sizeof *list); |
| 3406 | list->on = 0; | 3406 | list->on = 0; |
| 3407 | list->driver = driver; | 3407 | list->driver = driver; |
| 3408 | list->next = NULL; | 3408 | list->next = NULL; |
| @@ -3552,7 +3552,7 @@ font_put_frame_data (FRAME_PTR f, struct font_driver *driver, void *data) | |||
| 3552 | 3552 | ||
| 3553 | if (! list) | 3553 | if (! list) |
| 3554 | { | 3554 | { |
| 3555 | list = xmalloc (sizeof (struct font_data_list)); | 3555 | list = xmalloc (sizeof *list); |
| 3556 | list->driver = driver; | 3556 | list->driver = driver; |
| 3557 | list->next = f->font_data_list; | 3557 | list->next = f->font_data_list; |
| 3558 | f->font_data_list = list; | 3558 | f->font_data_list = list; |
diff --git a/src/fontset.c b/src/fontset.c index da54bca2a5c..cfaa24124f1 100644 --- a/src/fontset.c +++ b/src/fontset.c | |||
| @@ -1082,9 +1082,9 @@ fontset_pattern_regexp (Lisp_Object pattern) | |||
| 1082 | we convert "*" to "[^-]*" which is much faster in regular | 1082 | we convert "*" to "[^-]*" which is much faster in regular |
| 1083 | expression matching. */ | 1083 | expression matching. */ |
| 1084 | if (ndashes < 14) | 1084 | if (ndashes < 14) |
| 1085 | p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 2 * nstars + 2 * nescs + 1); | 1085 | p1 = regex = alloca (SBYTES (pattern) + 2 * nstars + 2 * nescs + 1); |
| 1086 | else | 1086 | else |
| 1087 | p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 5 * nstars + 2 * nescs + 1); | 1087 | p1 = regex = alloca (SBYTES (pattern) + 5 * nstars + 2 * nescs + 1); |
| 1088 | 1088 | ||
| 1089 | *p1++ = '^'; | 1089 | *p1++ = '^'; |
| 1090 | for (p0 = SDATA (pattern); *p0; p0++) | 1090 | for (p0 = SDATA (pattern); *p0; p0++) |
| @@ -1893,8 +1893,7 @@ format is the same as above. */) | |||
| 1893 | 1893 | ||
| 1894 | /* Recode fontsets realized on FRAME from the base fontset FONTSET | 1894 | /* Recode fontsets realized on FRAME from the base fontset FONTSET |
| 1895 | in the table `realized'. */ | 1895 | in the table `realized'. */ |
| 1896 | realized[0] = (Lisp_Object *) alloca (sizeof (Lisp_Object) | 1896 | realized[0] = alloca (sizeof (Lisp_Object) * ASIZE (Vfontset_table)); |
| 1897 | * ASIZE (Vfontset_table)); | ||
| 1898 | for (i = j = 0; i < ASIZE (Vfontset_table); i++) | 1897 | for (i = j = 0; i < ASIZE (Vfontset_table); i++) |
| 1899 | { | 1898 | { |
| 1900 | elt = FONTSET_FROM_ID (i); | 1899 | elt = FONTSET_FROM_ID (i); |
| @@ -1905,8 +1904,7 @@ format is the same as above. */) | |||
| 1905 | } | 1904 | } |
| 1906 | realized[0][j] = Qnil; | 1905 | realized[0][j] = Qnil; |
| 1907 | 1906 | ||
| 1908 | realized[1] = (Lisp_Object *) alloca (sizeof (Lisp_Object) | 1907 | realized[1] = alloca (sizeof (Lisp_Object) * ASIZE (Vfontset_table)); |
| 1909 | * ASIZE (Vfontset_table)); | ||
| 1910 | for (i = j = 0; ! NILP (realized[0][i]); i++) | 1908 | for (i = j = 0; ! NILP (realized[0][i]); i++) |
| 1911 | { | 1909 | { |
| 1912 | elt = FONTSET_DEFAULT (realized[0][i]); | 1910 | elt = FONTSET_DEFAULT (realized[0][i]); |
diff --git a/src/frame.c b/src/frame.c index 6ff336c40ee..8db943bd0a5 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -647,7 +647,7 @@ affects all frames on the same terminal device. */) | |||
| 647 | : NULL)); | 647 | : NULL)); |
| 648 | if (!NILP (tty)) | 648 | if (!NILP (tty)) |
| 649 | { | 649 | { |
| 650 | name = (char *) alloca (SBYTES (tty) + 1); | 650 | name = alloca (SBYTES (tty) + 1); |
| 651 | strncpy (name, SSDATA (tty), SBYTES (tty)); | 651 | strncpy (name, SSDATA (tty), SBYTES (tty)); |
| 652 | name[SBYTES (tty)] = 0; | 652 | name[SBYTES (tty)] = 0; |
| 653 | } | 653 | } |
| @@ -658,7 +658,7 @@ affects all frames on the same terminal device. */) | |||
| 658 | : NULL)); | 658 | : NULL)); |
| 659 | if (!NILP (tty_type)) | 659 | if (!NILP (tty_type)) |
| 660 | { | 660 | { |
| 661 | type = (char *) alloca (SBYTES (tty_type) + 1); | 661 | type = alloca (SBYTES (tty_type) + 1); |
| 662 | strncpy (type, SSDATA (tty_type), SBYTES (tty_type)); | 662 | strncpy (type, SSDATA (tty_type), SBYTES (tty_type)); |
| 663 | type[SBYTES (tty_type)] = 0; | 663 | type[SBYTES (tty_type)] = 0; |
| 664 | } | 664 | } |
| @@ -2762,8 +2762,8 @@ x_set_frame_parameters (FRAME_PTR f, Lisp_Object alist) | |||
| 2762 | for (tail = alist; CONSP (tail); tail = Fcdr (tail)) | 2762 | for (tail = alist; CONSP (tail); tail = Fcdr (tail)) |
| 2763 | i++; | 2763 | i++; |
| 2764 | 2764 | ||
| 2765 | parms = (Lisp_Object *) alloca (i * sizeof (Lisp_Object)); | 2765 | parms = alloca (i * sizeof *parms); |
| 2766 | values = (Lisp_Object *) alloca (i * sizeof (Lisp_Object)); | 2766 | values = alloca (i * sizeof *values); |
| 2767 | 2767 | ||
| 2768 | /* Extract parm names and values into those vectors. */ | 2768 | /* Extract parm names and values into those vectors. */ |
| 2769 | 2769 | ||
| @@ -3624,17 +3624,17 @@ xrdb_get_resource (XrmDatabase rdb, Lisp_Object attribute, Lisp_Object class, Li | |||
| 3624 | 3624 | ||
| 3625 | /* Allocate space for the components, the dots which separate them, | 3625 | /* Allocate space for the components, the dots which separate them, |
| 3626 | and the final '\0'. Make them big enough for the worst case. */ | 3626 | and the final '\0'. Make them big enough for the worst case. */ |
| 3627 | name_key = (char *) alloca (SBYTES (Vx_resource_name) | 3627 | name_key = alloca (SBYTES (Vx_resource_name) |
| 3628 | + (STRINGP (component) | 3628 | + (STRINGP (component) |
| 3629 | ? SBYTES (component) : 0) | 3629 | ? SBYTES (component) : 0) |
| 3630 | + SBYTES (attribute) | 3630 | + SBYTES (attribute) |
| 3631 | + 3); | 3631 | + 3); |
| 3632 | 3632 | ||
| 3633 | class_key = (char *) alloca (SBYTES (Vx_resource_class) | 3633 | class_key = alloca (SBYTES (Vx_resource_class) |
| 3634 | + SBYTES (class) | 3634 | + SBYTES (class) |
| 3635 | + (STRINGP (subclass) | 3635 | + (STRINGP (subclass) |
| 3636 | ? SBYTES (subclass) : 0) | 3636 | ? SBYTES (subclass) : 0) |
| 3637 | + 3); | 3637 | + 3); |
| 3638 | 3638 | ||
| 3639 | /* Start with emacs.FRAMENAME for the name (the specific one) | 3639 | /* Start with emacs.FRAMENAME for the name (the specific one) |
| 3640 | and with `Emacs' for the class key (the general one). */ | 3640 | and with `Emacs' for the class key (the general one). */ |
| @@ -3710,8 +3710,7 @@ x_get_resource_string (const char *attribute, const char *class) | |||
| 3710 | /* Allocate space for the components, the dots which separate them, | 3710 | /* Allocate space for the components, the dots which separate them, |
| 3711 | and the final '\0'. */ | 3711 | and the final '\0'. */ |
| 3712 | SAFE_ALLOCA (name_key, char *, invocation_namelen + strlen (attribute) + 2); | 3712 | SAFE_ALLOCA (name_key, char *, invocation_namelen + strlen (attribute) + 2); |
| 3713 | class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1) | 3713 | class_key = alloca ((sizeof (EMACS_CLASS) - 1) + strlen (class) + 2); |
| 3714 | + strlen (class) + 2); | ||
| 3715 | 3714 | ||
| 3716 | esprintf (name_key, "%s.%s", SSDATA (Vinvocation_name), attribute); | 3715 | esprintf (name_key, "%s.%s", SSDATA (Vinvocation_name), attribute); |
| 3717 | sprintf (class_key, "%s.%s", EMACS_CLASS, class); | 3716 | sprintf (class_key, "%s.%s", EMACS_CLASS, class); |
diff --git a/src/fringe.c b/src/fringe.c index cd3b87b43d4..4ab9c770326 100644 --- a/src/fringe.c +++ b/src/fringe.c | |||
| @@ -1616,12 +1616,10 @@ If BITMAP already exists, the existing definition is replaced. */) | |||
| 1616 | error ("No free fringe bitmap slots"); | 1616 | error ("No free fringe bitmap slots"); |
| 1617 | 1617 | ||
| 1618 | i = max_fringe_bitmaps; | 1618 | i = max_fringe_bitmaps; |
| 1619 | fringe_bitmaps | 1619 | fringe_bitmaps = xrealloc (fringe_bitmaps, |
| 1620 | = ((struct fringe_bitmap **) | 1620 | bitmaps * sizeof *fringe_bitmaps); |
| 1621 | xrealloc (fringe_bitmaps, bitmaps * sizeof *fringe_bitmaps)); | 1621 | fringe_faces = xrealloc (fringe_faces, |
| 1622 | fringe_faces | 1622 | bitmaps * sizeof *fringe_faces); |
| 1623 | = (Lisp_Object *) xrealloc (fringe_faces, | ||
| 1624 | bitmaps * sizeof *fringe_faces); | ||
| 1625 | 1623 | ||
| 1626 | for (i = max_fringe_bitmaps; i < bitmaps; i++) | 1624 | for (i = max_fringe_bitmaps; i < bitmaps; i++) |
| 1627 | { | 1625 | { |
| @@ -1803,9 +1801,8 @@ init_fringe (void) | |||
| 1803 | 1801 | ||
| 1804 | max_fringe_bitmaps = MAX_STANDARD_FRINGE_BITMAPS + 20; | 1802 | max_fringe_bitmaps = MAX_STANDARD_FRINGE_BITMAPS + 20; |
| 1805 | 1803 | ||
| 1806 | fringe_bitmaps | 1804 | fringe_bitmaps = xzalloc (max_fringe_bitmaps * sizeof *fringe_bitmaps); |
| 1807 | = xzalloc (max_fringe_bitmaps * sizeof (struct fringe_bitmap *)); | 1805 | fringe_faces = xmalloc (max_fringe_bitmaps * sizeof *fringe_faces); |
| 1808 | fringe_faces = xmalloc (max_fringe_bitmaps * sizeof (Lisp_Object)); | ||
| 1809 | 1806 | ||
| 1810 | for (i = 0; i < max_fringe_bitmaps; i++) | 1807 | for (i = 0; i < max_fringe_bitmaps; i++) |
| 1811 | fringe_faces[i] = Qnil; | 1808 | fringe_faces[i] = Qnil; |
diff --git a/src/ftfont.c b/src/ftfont.c index 29732e4c870..8e322369868 100644 --- a/src/ftfont.c +++ b/src/ftfont.c | |||
| @@ -392,7 +392,7 @@ ftfont_lookup_cache (Lisp_Object key, enum ftfont_cache_for cache_for) | |||
| 392 | args[1] = Qequal; | 392 | args[1] = Qequal; |
| 393 | ft_face_cache = Fmake_hash_table (2, args); | 393 | ft_face_cache = Fmake_hash_table (2, args); |
| 394 | } | 394 | } |
| 395 | cache_data = xmalloc (sizeof (struct ftfont_cache_data)); | 395 | cache_data = xmalloc (sizeof *cache_data); |
| 396 | cache_data->ft_face = NULL; | 396 | cache_data->ft_face = NULL; |
| 397 | cache_data->fc_charset = NULL; | 397 | cache_data->fc_charset = NULL; |
| 398 | val = make_save_value (NULL, 0); | 398 | val = make_save_value (NULL, 0); |
| @@ -657,7 +657,7 @@ struct OpenTypeSpec | |||
| 657 | static struct OpenTypeSpec * | 657 | static struct OpenTypeSpec * |
| 658 | ftfont_get_open_type_spec (Lisp_Object otf_spec) | 658 | ftfont_get_open_type_spec (Lisp_Object otf_spec) |
| 659 | { | 659 | { |
| 660 | struct OpenTypeSpec *spec = malloc (sizeof (struct OpenTypeSpec)); | 660 | struct OpenTypeSpec *spec = malloc (sizeof *spec); |
| 661 | Lisp_Object val; | 661 | Lisp_Object val; |
| 662 | int i, j, negative; | 662 | int i, j, negative; |
| 663 | 663 | ||
| @@ -696,7 +696,7 @@ ftfont_get_open_type_spec (Lisp_Object otf_spec) | |||
| 696 | spec->features[i] = | 696 | spec->features[i] = |
| 697 | (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (int) < XINT (len) | 697 | (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (int) < XINT (len) |
| 698 | ? 0 | 698 | ? 0 |
| 699 | : malloc (sizeof (int) * XINT (len))); | 699 | : malloc (XINT (len) * sizeof *spec->features[i])); |
| 700 | if (! spec->features[i]) | 700 | if (! spec->features[i]) |
| 701 | { | 701 | { |
| 702 | if (i > 0 && spec->features[0]) | 702 | if (i > 0 && spec->features[0]) |
| @@ -2460,15 +2460,16 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font, | |||
| 2460 | if (gstring.allocated == 0) | 2460 | if (gstring.allocated == 0) |
| 2461 | { | 2461 | { |
| 2462 | gstring.glyph_size = sizeof (MFLTGlyph); | 2462 | gstring.glyph_size = sizeof (MFLTGlyph); |
| 2463 | gstring.glyphs = xnmalloc (len * 2, sizeof (MFLTGlyph)); | 2463 | gstring.glyphs = xnmalloc (len * 2, sizeof *gstring.glyphs); |
| 2464 | gstring.allocated = len * 2; | 2464 | gstring.allocated = len * 2; |
| 2465 | } | 2465 | } |
| 2466 | else if (gstring.allocated < len * 2) | 2466 | else if (gstring.allocated < len * 2) |
| 2467 | { | 2467 | { |
| 2468 | gstring.glyphs = xnrealloc (gstring.glyphs, len * 2, sizeof (MFLTGlyph)); | 2468 | gstring.glyphs = xnrealloc (gstring.glyphs, len * 2, |
| 2469 | sizeof *gstring.glyphs); | ||
| 2469 | gstring.allocated = len * 2; | 2470 | gstring.allocated = len * 2; |
| 2470 | } | 2471 | } |
| 2471 | memset (gstring.glyphs, 0, sizeof (MFLTGlyph) * len); | 2472 | memset (gstring.glyphs, 0, len * sizeof *gstring.glyphs); |
| 2472 | for (i = 0; i < len; i++) | 2473 | for (i = 0; i < len; i++) |
| 2473 | { | 2474 | { |
| 2474 | Lisp_Object g = LGSTRING_GLYPH (lgstring, i); | 2475 | Lisp_Object g = LGSTRING_GLYPH (lgstring, i); |
diff --git a/src/ftxfont.c b/src/ftxfont.c index 9fe4d41dcc5..6ebe0798b4e 100644 --- a/src/ftxfont.c +++ b/src/ftxfont.c | |||
| @@ -90,7 +90,7 @@ ftxfont_get_gcs (FRAME_PTR f, long unsigned int foreground, long unsigned int ba | |||
| 90 | } | 90 | } |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | new = malloc (sizeof (struct ftxfont_frame_data)); | 93 | new = malloc (sizeof *new); |
| 94 | if (! new) | 94 | if (! new) |
| 95 | return NULL; | 95 | return NULL; |
| 96 | new->next = this; | 96 | new->next = this; |
diff --git a/src/gmalloc.c b/src/gmalloc.c index 3de3733d55f..3739214bc46 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c | |||
| @@ -1616,7 +1616,7 @@ memalign (size_t alignment, size_t size) | |||
| 1616 | break; | 1616 | break; |
| 1617 | if (l == NULL) | 1617 | if (l == NULL) |
| 1618 | { | 1618 | { |
| 1619 | l = malloc (sizeof (struct alignlist)); | 1619 | l = malloc (sizeof *l); |
| 1620 | if (l != NULL) | 1620 | if (l != NULL) |
| 1621 | { | 1621 | { |
| 1622 | l->next = _aligned_blocks; | 1622 | l->next = _aligned_blocks; |
| @@ -1811,7 +1811,7 @@ mallochook (size_t size) | |||
| 1811 | struct hdr *hdr; | 1811 | struct hdr *hdr; |
| 1812 | 1812 | ||
| 1813 | __malloc_hook = old_malloc_hook; | 1813 | __malloc_hook = old_malloc_hook; |
| 1814 | hdr = malloc (sizeof (struct hdr) + size + 1); | 1814 | hdr = malloc (sizeof *hdr + size + 1); |
| 1815 | __malloc_hook = mallochook; | 1815 | __malloc_hook = mallochook; |
| 1816 | if (hdr == NULL) | 1816 | if (hdr == NULL) |
| 1817 | return NULL; | 1817 | return NULL; |
| @@ -1842,7 +1842,7 @@ reallochook (void *ptr, size_t size) | |||
| 1842 | __free_hook = old_free_hook; | 1842 | __free_hook = old_free_hook; |
| 1843 | __malloc_hook = old_malloc_hook; | 1843 | __malloc_hook = old_malloc_hook; |
| 1844 | __realloc_hook = old_realloc_hook; | 1844 | __realloc_hook = old_realloc_hook; |
| 1845 | hdr = realloc (hdr, sizeof (struct hdr) + size + 1); | 1845 | hdr = realloc (hdr, sizeof *hdr + size + 1); |
| 1846 | __free_hook = freehook; | 1846 | __free_hook = freehook; |
| 1847 | __malloc_hook = mallochook; | 1847 | __malloc_hook = mallochook; |
| 1848 | __realloc_hook = reallochook; | 1848 | __realloc_hook = reallochook; |
diff --git a/src/gtkutil.c b/src/gtkutil.c index 25a81c45436..82c7d643551 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -215,7 +215,7 @@ malloc_widget_value (void) | |||
| 215 | } | 215 | } |
| 216 | else | 216 | else |
| 217 | { | 217 | { |
| 218 | wv = xmalloc (sizeof (widget_value)); | 218 | wv = xmalloc (sizeof *wv); |
| 219 | malloc_cpt++; | 219 | malloc_cpt++; |
| 220 | } | 220 | } |
| 221 | memset (wv, 0, sizeof (widget_value)); | 221 | memset (wv, 0, sizeof (widget_value)); |
| @@ -2057,7 +2057,7 @@ make_cl_data (xg_menu_cb_data *cl_data, FRAME_PTR f, GCallback highlight_cb) | |||
| 2057 | { | 2057 | { |
| 2058 | if (! cl_data) | 2058 | if (! cl_data) |
| 2059 | { | 2059 | { |
| 2060 | cl_data = xmalloc (sizeof (*cl_data)); | 2060 | cl_data = xmalloc (sizeof *cl_data); |
| 2061 | cl_data->f = f; | 2061 | cl_data->f = f; |
| 2062 | cl_data->menu_bar_vector = f->menu_bar_vector; | 2062 | cl_data->menu_bar_vector = f->menu_bar_vector; |
| 2063 | cl_data->menu_bar_items_used = f->menu_bar_items_used; | 2063 | cl_data->menu_bar_items_used = f->menu_bar_items_used; |
| @@ -2357,7 +2357,7 @@ xg_create_one_menuitem (widget_value *item, | |||
| 2357 | if (utf8_label) g_free (utf8_label); | 2357 | if (utf8_label) g_free (utf8_label); |
| 2358 | if (utf8_key) g_free (utf8_key); | 2358 | if (utf8_key) g_free (utf8_key); |
| 2359 | 2359 | ||
| 2360 | cb_data = xmalloc (sizeof (xg_menu_item_cb_data)); | 2360 | cb_data = xmalloc (sizeof *cb_data); |
| 2361 | 2361 | ||
| 2362 | xg_list_insert (&xg_menu_item_cb_list, &cb_data->ptrs); | 2362 | xg_list_insert (&xg_menu_item_cb_list, &cb_data->ptrs); |
| 2363 | 2363 | ||
| @@ -4336,7 +4336,7 @@ is_box_type (GtkWidget *vb, int is_horizontal) | |||
| 4336 | { | 4336 | { |
| 4337 | #ifdef HAVE_GTK3 | 4337 | #ifdef HAVE_GTK3 |
| 4338 | int ret = 0; | 4338 | int ret = 0; |
| 4339 | if (GTK_IS_BOX (vb)) | 4339 | if (GTK_IS_BOX (vb)) |
| 4340 | { | 4340 | { |
| 4341 | GtkOrientation ori = gtk_orientable_get_orientation (GTK_ORIENTABLE (vb)); | 4341 | GtkOrientation ori = gtk_orientable_get_orientation (GTK_ORIENTABLE (vb)); |
| 4342 | ret = (ori == GTK_ORIENTATION_HORIZONTAL && is_horizontal) | 4342 | ret = (ori == GTK_ORIENTATION_HORIZONTAL && is_horizontal) |
diff --git a/src/image.c b/src/image.c index 45dcb554439..4877d262d00 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -1356,9 +1356,7 @@ x_alloc_image_color (struct frame *f, struct image *img, Lisp_Object color_name, | |||
| 1356 | /* This isn't called frequently so we get away with simply | 1356 | /* This isn't called frequently so we get away with simply |
| 1357 | reallocating the color vector to the needed size, here. */ | 1357 | reallocating the color vector to the needed size, here. */ |
| 1358 | ptrdiff_t ncolors = img->ncolors + 1; | 1358 | ptrdiff_t ncolors = img->ncolors + 1; |
| 1359 | img->colors = | 1359 | img->colors = xrealloc (img->colors, ncolors * sizeof *img->colors); |
| 1360 | (unsigned long *) xrealloc (img->colors, | ||
| 1361 | ncolors * sizeof *img->colors); | ||
| 1362 | img->colors[ncolors - 1] = color.pixel; | 1360 | img->colors[ncolors - 1] = color.pixel; |
| 1363 | img->ncolors = ncolors; | 1361 | img->ncolors = ncolors; |
| 1364 | result = color.pixel; | 1362 | result = color.pixel; |
| @@ -2500,7 +2498,7 @@ w32_create_pixmap_from_bitmap_data (int width, int height, char *data) | |||
| 2500 | 2498 | ||
| 2501 | w1 = (width + 7) / 8; /* nb of 8bits elt in X bitmap */ | 2499 | w1 = (width + 7) / 8; /* nb of 8bits elt in X bitmap */ |
| 2502 | w2 = ((width + 15) / 16) * 2; /* nb of 16bits elt in W32 bitmap */ | 2500 | w2 = ((width + 15) / 16) * 2; /* nb of 16bits elt in W32 bitmap */ |
| 2503 | bits = (unsigned char *) alloca (height * w2); | 2501 | bits = alloca (height * w2); |
| 2504 | memset (bits, 0, height * w2); | 2502 | memset (bits, 0, height * w2); |
| 2505 | for (i = 0; i < height; i++) | 2503 | for (i = 0; i < height; i++) |
| 2506 | { | 2504 | { |
| @@ -2927,7 +2925,7 @@ xbm_load (struct frame *f, struct image *img) | |||
| 2927 | char *p; | 2925 | char *p; |
| 2928 | int nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR; | 2926 | int nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR; |
| 2929 | 2927 | ||
| 2930 | p = bits = (char *) alloca (nbytes * img->height); | 2928 | p = bits = alloca (nbytes * img->height); |
| 2931 | for (i = 0; i < img->height; ++i, p += nbytes) | 2929 | for (i = 0; i < img->height; ++i, p += nbytes) |
| 2932 | { | 2930 | { |
| 2933 | Lisp_Object line = AREF (data, i); | 2931 | Lisp_Object line = AREF (data, i); |
| @@ -2950,7 +2948,7 @@ xbm_load (struct frame *f, struct image *img) | |||
| 2950 | invertedBits = bits; | 2948 | invertedBits = bits; |
| 2951 | nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR | 2949 | nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR |
| 2952 | * img->height; | 2950 | * img->height; |
| 2953 | bits = (char *) alloca (nbytes); | 2951 | bits = alloca (nbytes); |
| 2954 | for (i = 0; i < nbytes; i++) | 2952 | for (i = 0; i < nbytes; i++) |
| 2955 | bits[i] = XBM_BIT_SHUFFLE (invertedBits[i]); | 2953 | bits[i] = XBM_BIT_SHUFFLE (invertedBits[i]); |
| 2956 | } | 2954 | } |
| @@ -3422,7 +3420,7 @@ xpm_load (struct frame *f, struct image *img) | |||
| 3422 | 3420 | ||
| 3423 | /* Allocate an XpmColorSymbol array. */ | 3421 | /* Allocate an XpmColorSymbol array. */ |
| 3424 | size = attrs.numsymbols * sizeof *xpm_syms; | 3422 | size = attrs.numsymbols * sizeof *xpm_syms; |
| 3425 | xpm_syms = (XpmColorSymbol *) alloca (size); | 3423 | xpm_syms = alloca (size); |
| 3426 | memset (xpm_syms, 0, size); | 3424 | memset (xpm_syms, 0, size); |
| 3427 | attrs.colorsymbols = xpm_syms; | 3425 | attrs.colorsymbols = xpm_syms; |
| 3428 | 3426 | ||
| @@ -3445,14 +3443,14 @@ xpm_load (struct frame *f, struct image *img) | |||
| 3445 | color = XCDR (XCAR (tail)); | 3443 | color = XCDR (XCAR (tail)); |
| 3446 | if (STRINGP (name)) | 3444 | if (STRINGP (name)) |
| 3447 | { | 3445 | { |
| 3448 | xpm_syms[i].name = (char *) alloca (SCHARS (name) + 1); | 3446 | xpm_syms[i].name = alloca (SCHARS (name) + 1); |
| 3449 | strcpy (xpm_syms[i].name, SSDATA (name)); | 3447 | strcpy (xpm_syms[i].name, SSDATA (name)); |
| 3450 | } | 3448 | } |
| 3451 | else | 3449 | else |
| 3452 | xpm_syms[i].name = empty_string; | 3450 | xpm_syms[i].name = empty_string; |
| 3453 | if (STRINGP (color)) | 3451 | if (STRINGP (color)) |
| 3454 | { | 3452 | { |
| 3455 | xpm_syms[i].value = (char *) alloca (SCHARS (color) + 1); | 3453 | xpm_syms[i].value = alloca (SCHARS (color) + 1); |
| 3456 | strcpy (xpm_syms[i].value, SSDATA (color)); | 3454 | strcpy (xpm_syms[i].value, SSDATA (color)); |
| 3457 | } | 3455 | } |
| 3458 | else | 3456 | else |
| @@ -6449,8 +6447,7 @@ jpeg_load (struct frame *f, struct image *img) | |||
| 6449 | a default color, and we don't have to care about which colors | 6447 | a default color, and we don't have to care about which colors |
| 6450 | can be freed safely, and which can't. */ | 6448 | can be freed safely, and which can't. */ |
| 6451 | init_color_table (); | 6449 | init_color_table (); |
| 6452 | colors = (unsigned long *) alloca (cinfo.actual_number_of_colors | 6450 | colors = alloca (cinfo.actual_number_of_colors * sizeof *colors); |
| 6453 | * sizeof *colors); | ||
| 6454 | 6451 | ||
| 6455 | for (i = 0; i < cinfo.actual_number_of_colors; ++i) | 6452 | for (i = 0; i < cinfo.actual_number_of_colors; ++i) |
| 6456 | { | 6453 | { |
diff --git a/src/keyboard.c b/src/keyboard.c index 0d686e299c5..93f073986f2 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -480,7 +480,7 @@ echo_char (Lisp_Object c) | |||
| 480 | if (current_kboard->immediate_echo) | 480 | if (current_kboard->immediate_echo) |
| 481 | { | 481 | { |
| 482 | int size = KEY_DESCRIPTION_SIZE + 100; | 482 | int size = KEY_DESCRIPTION_SIZE + 100; |
| 483 | char *buffer = (char *) alloca (size); | 483 | char *buffer = alloca (size); |
| 484 | char *ptr = buffer; | 484 | char *ptr = buffer; |
| 485 | Lisp_Object echo_string; | 485 | Lisp_Object echo_string; |
| 486 | 486 | ||
| @@ -502,7 +502,7 @@ echo_char (Lisp_Object c) | |||
| 502 | { | 502 | { |
| 503 | int offset = ptr - buffer; | 503 | int offset = ptr - buffer; |
| 504 | size = max (2 * size, size + nbytes); | 504 | size = max (2 * size, size + nbytes); |
| 505 | buffer = (char *) alloca (size); | 505 | buffer = alloca (size); |
| 506 | ptr = buffer + offset; | 506 | ptr = buffer + offset; |
| 507 | } | 507 | } |
| 508 | 508 | ||
| @@ -520,7 +520,7 @@ echo_char (Lisp_Object c) | |||
| 520 | { | 520 | { |
| 521 | int offset = ptr - buffer; | 521 | int offset = ptr - buffer; |
| 522 | size += len; | 522 | size += len; |
| 523 | buffer = (char *) alloca (size); | 523 | buffer = alloca (size); |
| 524 | ptr = buffer + offset; | 524 | ptr = buffer + offset; |
| 525 | } | 525 | } |
| 526 | 526 | ||
| @@ -884,7 +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 = xmalloc (sizeof (struct kboard_stack)); | 887 | struct kboard_stack *p = xmalloc (sizeof *p); |
| 888 | 888 | ||
| 889 | p->next = kboard_stack; | 889 | p->next = kboard_stack; |
| 890 | p->kboard = current_kboard; | 890 | p->kboard = current_kboard; |
| @@ -6196,8 +6196,7 @@ apply_modifiers_uncached (int modifiers, char *base, int base_len, int base_len_ | |||
| 6196 | /* Since BASE could contain nulls, we can't use intern here; we have | 6196 | /* Since BASE could contain nulls, we can't use intern here; we have |
| 6197 | to use Fintern, which expects a genuine Lisp_String, and keeps a | 6197 | to use Fintern, which expects a genuine Lisp_String, and keeps a |
| 6198 | reference to it. */ | 6198 | reference to it. */ |
| 6199 | char *new_mods | 6199 | char new_mods[sizeof "A-C-H-M-S-s-down-drag-double-triple-"]; |
| 6200 | = (char *) alloca (sizeof ("A-C-H-M-S-s-down-drag-double-triple-")); | ||
| 6201 | int mod_len; | 6200 | int mod_len; |
| 6202 | 6201 | ||
| 6203 | { | 6202 | { |
| @@ -7280,7 +7279,7 @@ add_user_signal (int sig, const char *name) | |||
| 7280 | /* Already added. */ | 7279 | /* Already added. */ |
| 7281 | return; | 7280 | return; |
| 7282 | 7281 | ||
| 7283 | p = xmalloc (sizeof (struct user_signal_info)); | 7282 | p = xmalloc (sizeof *p); |
| 7284 | p->sig = sig; | 7283 | p->sig = sig; |
| 7285 | p->name = xstrdup (name); | 7284 | p->name = xstrdup (name); |
| 7286 | p->npending = 0; | 7285 | p->npending = 0; |
| @@ -7506,7 +7505,7 @@ menu_bar_items (Lisp_Object old) | |||
| 7506 | Lisp_Object tem; | 7505 | Lisp_Object tem; |
| 7507 | ptrdiff_t nminor; | 7506 | ptrdiff_t nminor; |
| 7508 | nminor = current_minor_maps (NULL, &tmaps); | 7507 | nminor = current_minor_maps (NULL, &tmaps); |
| 7509 | maps = (Lisp_Object *) alloca ((nminor + 3) * sizeof (maps[0])); | 7508 | maps = alloca ((nminor + 3) * sizeof *maps); |
| 7510 | nmaps = 0; | 7509 | nmaps = 0; |
| 7511 | if (tem = get_local_map (PT, current_buffer, Qkeymap), !NILP (tem)) | 7510 | if (tem = get_local_map (PT, current_buffer, Qkeymap), !NILP (tem)) |
| 7512 | maps[nmaps++] = tem; | 7511 | maps[nmaps++] = tem; |
| @@ -8033,7 +8032,7 @@ tool_bar_items (Lisp_Object reuse, int *nitems) | |||
| 8033 | if (!NILP (Voverriding_local_map_menu_flag)) | 8032 | if (!NILP (Voverriding_local_map_menu_flag)) |
| 8034 | { | 8033 | { |
| 8035 | /* Yes, use them (if non-nil) as well as the global map. */ | 8034 | /* Yes, use them (if non-nil) as well as the global map. */ |
| 8036 | maps = (Lisp_Object *) alloca (3 * sizeof (maps[0])); | 8035 | maps = alloca (3 * sizeof *maps); |
| 8037 | nmaps = 0; | 8036 | nmaps = 0; |
| 8038 | if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map))) | 8037 | if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map))) |
| 8039 | maps[nmaps++] = KVAR (current_kboard, Voverriding_terminal_local_map); | 8038 | maps[nmaps++] = KVAR (current_kboard, Voverriding_terminal_local_map); |
| @@ -8050,7 +8049,7 @@ tool_bar_items (Lisp_Object reuse, int *nitems) | |||
| 8050 | Lisp_Object tem; | 8049 | Lisp_Object tem; |
| 8051 | ptrdiff_t nminor; | 8050 | ptrdiff_t nminor; |
| 8052 | nminor = current_minor_maps (NULL, &tmaps); | 8051 | nminor = current_minor_maps (NULL, &tmaps); |
| 8053 | maps = (Lisp_Object *) alloca ((nminor + 3) * sizeof (maps[0])); | 8052 | maps = alloca ((nminor + 3) * sizeof *maps); |
| 8054 | nmaps = 0; | 8053 | nmaps = 0; |
| 8055 | if (tem = get_local_map (PT, current_buffer, Qkeymap), !NILP (tem)) | 8054 | if (tem = get_local_map (PT, current_buffer, Qkeymap), !NILP (tem)) |
| 8056 | maps[nmaps++] = tem; | 8055 | maps[nmaps++] = tem; |
| @@ -8475,8 +8474,7 @@ read_char_x_menu_prompt (ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 8475 | && !EQ (XCAR (prev_event), Qtool_bar)) | 8474 | && !EQ (XCAR (prev_event), Qtool_bar)) |
| 8476 | { | 8475 | { |
| 8477 | /* Display the menu and get the selection. */ | 8476 | /* Display the menu and get the selection. */ |
| 8478 | Lisp_Object *realmaps | 8477 | Lisp_Object *realmaps = alloca (nmaps * sizeof *realmaps); |
| 8479 | = (Lisp_Object *) alloca (nmaps * sizeof (Lisp_Object)); | ||
| 8480 | Lisp_Object value; | 8478 | Lisp_Object value; |
| 8481 | ptrdiff_t nmaps1 = 0; | 8479 | ptrdiff_t nmaps1 = 0; |
| 8482 | 8480 | ||
| @@ -8570,7 +8568,7 @@ read_char_minibuf_menu_prompt (int commandflag, | |||
| 8570 | if (width + 4 > read_char_minibuf_menu_width) | 8568 | if (width + 4 > read_char_minibuf_menu_width) |
| 8571 | { | 8569 | { |
| 8572 | read_char_minibuf_menu_text | 8570 | read_char_minibuf_menu_text |
| 8573 | = (char *) xrealloc (read_char_minibuf_menu_text, width + 4); | 8571 | = xrealloc (read_char_minibuf_menu_text, width + 4); |
| 8574 | read_char_minibuf_menu_width = width + 4; | 8572 | read_char_minibuf_menu_width = width + 4; |
| 8575 | } | 8573 | } |
| 8576 | menu = read_char_minibuf_menu_text; | 8574 | menu = read_char_minibuf_menu_text; |
| @@ -9177,8 +9175,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9177 | { | 9175 | { |
| 9178 | if (2 > nmaps_allocated) | 9176 | if (2 > nmaps_allocated) |
| 9179 | { | 9177 | { |
| 9180 | submaps = (Lisp_Object *) alloca (2 * sizeof (submaps[0])); | 9178 | submaps = alloca (2 * sizeof *submaps); |
| 9181 | defs = (Lisp_Object *) alloca (2 * sizeof (defs[0])); | 9179 | defs = alloca (2 * sizeof *defs); |
| 9182 | nmaps_allocated = 2; | 9180 | nmaps_allocated = 2; |
| 9183 | } | 9181 | } |
| 9184 | submaps[nmaps++] = KVAR (current_kboard, Voverriding_terminal_local_map); | 9182 | submaps[nmaps++] = KVAR (current_kboard, Voverriding_terminal_local_map); |
| @@ -9187,8 +9185,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9187 | { | 9185 | { |
| 9188 | if (2 > nmaps_allocated) | 9186 | if (2 > nmaps_allocated) |
| 9189 | { | 9187 | { |
| 9190 | submaps = (Lisp_Object *) alloca (2 * sizeof (submaps[0])); | 9188 | submaps = alloca (2 * sizeof *submaps); |
| 9191 | defs = (Lisp_Object *) alloca (2 * sizeof (defs[0])); | 9189 | defs = alloca (2 * sizeof *defs); |
| 9192 | nmaps_allocated = 2; | 9190 | nmaps_allocated = 2; |
| 9193 | } | 9191 | } |
| 9194 | submaps[nmaps++] = Voverriding_local_map; | 9192 | submaps[nmaps++] = Voverriding_local_map; |
| @@ -9204,8 +9202,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9204 | 9202 | ||
| 9205 | if (total > nmaps_allocated) | 9203 | if (total > nmaps_allocated) |
| 9206 | { | 9204 | { |
| 9207 | submaps = (Lisp_Object *) alloca (total * sizeof (submaps[0])); | 9205 | submaps = alloca (total * sizeof *submaps); |
| 9208 | defs = (Lisp_Object *) alloca (total * sizeof (defs[0])); | 9206 | defs = alloca (total * sizeof *defs); |
| 9209 | nmaps_allocated = total; | 9207 | nmaps_allocated = total; |
| 9210 | } | 9208 | } |
| 9211 | 9209 | ||
| @@ -12187,7 +12185,7 @@ variable are `sigusr1' and `sigusr2'. */); | |||
| 12187 | Vdebug_on_event = intern_c_string ("sigusr2"); | 12185 | Vdebug_on_event = intern_c_string ("sigusr2"); |
| 12188 | 12186 | ||
| 12189 | /* Create the initial keyboard. */ | 12187 | /* Create the initial keyboard. */ |
| 12190 | initial_kboard = xmalloc (sizeof (KBOARD)); | 12188 | initial_kboard = xmalloc (sizeof *initial_kboard); |
| 12191 | init_kboard (initial_kboard); | 12189 | init_kboard (initial_kboard); |
| 12192 | /* Vwindow_system is left at t for now. */ | 12190 | /* Vwindow_system is left at t for now. */ |
| 12193 | initial_kboard->next_kboard = all_kboards; | 12191 | initial_kboard->next_kboard = all_kboards; |
diff --git a/src/keymap.c b/src/keymap.c index db4d5d12ee4..234740721ae 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -1478,7 +1478,7 @@ current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr) | |||
| 1478 | /* Use malloc here. See the comment above this function. | 1478 | /* Use malloc here. See the comment above this function. |
| 1479 | Avoid realloc here; it causes spurious traps on GNU/Linux [KFS] */ | 1479 | Avoid realloc here; it causes spurious traps on GNU/Linux [KFS] */ |
| 1480 | BLOCK_INPUT; | 1480 | BLOCK_INPUT; |
| 1481 | newmodes = (Lisp_Object *) malloc (allocsize); | 1481 | newmodes = malloc (allocsize); |
| 1482 | if (newmodes) | 1482 | if (newmodes) |
| 1483 | { | 1483 | { |
| 1484 | if (cmm_modes) | 1484 | if (cmm_modes) |
| @@ -1490,7 +1490,7 @@ current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr) | |||
| 1490 | cmm_modes = newmodes; | 1490 | cmm_modes = newmodes; |
| 1491 | } | 1491 | } |
| 1492 | 1492 | ||
| 1493 | newmaps = (Lisp_Object *) malloc (allocsize); | 1493 | newmaps = malloc (allocsize); |
| 1494 | if (newmaps) | 1494 | if (newmaps) |
| 1495 | { | 1495 | { |
| 1496 | if (cmm_maps) | 1496 | if (cmm_maps) |
| @@ -2923,7 +2923,7 @@ You type Translation\n\ | |||
| 2923 | if (!SYMBOLP (modes[i])) | 2923 | if (!SYMBOLP (modes[i])) |
| 2924 | abort (); | 2924 | abort (); |
| 2925 | 2925 | ||
| 2926 | p = title = (char *) alloca (42 + SCHARS (SYMBOL_NAME (modes[i]))); | 2926 | p = title = alloca (42 + SCHARS (SYMBOL_NAME (modes[i]))); |
| 2927 | *p++ = '\f'; | 2927 | *p++ = '\f'; |
| 2928 | *p++ = '\n'; | 2928 | *p++ = '\n'; |
| 2929 | *p++ = '`'; | 2929 | *p++ = '`'; |
diff --git a/src/lread.c b/src/lread.c index 670831081e8..19783d3102b 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -1479,7 +1479,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto | |||
| 1479 | this path element/specified file name and any possible suffix. */ | 1479 | this path element/specified file name and any possible suffix. */ |
| 1480 | want_length = max_suffix_len + SBYTES (filename); | 1480 | want_length = max_suffix_len + SBYTES (filename); |
| 1481 | if (fn_size <= want_length) | 1481 | if (fn_size <= want_length) |
| 1482 | fn = (char *) alloca (fn_size = 100 + want_length); | 1482 | fn = alloca (fn_size = 100 + want_length); |
| 1483 | 1483 | ||
| 1484 | /* Loop over suffixes. */ | 1484 | /* Loop over suffixes. */ |
| 1485 | for (tail = NILP (suffixes) ? Fcons (empty_unibyte_string, Qnil) : suffixes; | 1485 | for (tail = NILP (suffixes) ? Fcons (empty_unibyte_string, Qnil) : suffixes; |
| @@ -2630,8 +2630,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2630 | } | 2630 | } |
| 2631 | if (nskip > saved_doc_string_size) | 2631 | if (nskip > saved_doc_string_size) |
| 2632 | { | 2632 | { |
| 2633 | saved_doc_string = (char *) xrealloc (saved_doc_string, | 2633 | saved_doc_string = xrealloc (saved_doc_string, nskip + extra); |
| 2634 | nskip + extra); | ||
| 2635 | saved_doc_string_size = nskip + extra; | 2634 | saved_doc_string_size = nskip + extra; |
| 2636 | } | 2635 | } |
| 2637 | 2636 | ||
| @@ -2894,8 +2893,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2894 | ptrdiff_t offset = p - read_buffer; | 2893 | ptrdiff_t offset = p - read_buffer; |
| 2895 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) | 2894 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) |
| 2896 | memory_full (SIZE_MAX); | 2895 | memory_full (SIZE_MAX); |
| 2897 | read_buffer = (char *) xrealloc (read_buffer, | 2896 | read_buffer = xrealloc (read_buffer, read_buffer_size * 2); |
| 2898 | read_buffer_size * 2); | ||
| 2899 | read_buffer_size *= 2; | 2897 | read_buffer_size *= 2; |
| 2900 | p = read_buffer + offset; | 2898 | p = read_buffer + offset; |
| 2901 | end = read_buffer + read_buffer_size; | 2899 | end = read_buffer + read_buffer_size; |
| @@ -3029,8 +3027,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 3029 | ptrdiff_t offset = p - read_buffer; | 3027 | ptrdiff_t offset = p - read_buffer; |
| 3030 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) | 3028 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) |
| 3031 | memory_full (SIZE_MAX); | 3029 | memory_full (SIZE_MAX); |
| 3032 | read_buffer = (char *) xrealloc (read_buffer, | 3030 | read_buffer = xrealloc (read_buffer, read_buffer_size * 2); |
| 3033 | read_buffer_size * 2); | ||
| 3034 | read_buffer_size *= 2; | 3031 | read_buffer_size *= 2; |
| 3035 | p = read_buffer + offset; | 3032 | p = read_buffer + offset; |
| 3036 | end = read_buffer + read_buffer_size; | 3033 | end = read_buffer + read_buffer_size; |
| @@ -3060,8 +3057,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 3060 | ptrdiff_t offset = p - read_buffer; | 3057 | ptrdiff_t offset = p - read_buffer; |
| 3061 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) | 3058 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) |
| 3062 | memory_full (SIZE_MAX); | 3059 | memory_full (SIZE_MAX); |
| 3063 | read_buffer = (char *) xrealloc (read_buffer, | 3060 | read_buffer = xrealloc (read_buffer, read_buffer_size * 2); |
| 3064 | read_buffer_size * 2); | ||
| 3065 | read_buffer_size *= 2; | 3061 | read_buffer_size *= 2; |
| 3066 | p = read_buffer + offset; | 3062 | p = read_buffer + offset; |
| 3067 | end = read_buffer + read_buffer_size; | 3063 | end = read_buffer + read_buffer_size; |
diff --git a/src/macros.c b/src/macros.c index 7c8bc4c13b8..0b1eda0b8ab 100644 --- a/src/macros.c +++ b/src/macros.c | |||
| @@ -63,8 +63,7 @@ macro before appending to it. */) | |||
| 63 | 63 | ||
| 64 | if (!current_kboard->kbd_macro_buffer) | 64 | if (!current_kboard->kbd_macro_buffer) |
| 65 | { | 65 | { |
| 66 | current_kboard->kbd_macro_buffer | 66 | current_kboard->kbd_macro_buffer = xmalloc (30 * sizeof (Lisp_Object)); |
| 67 | = (Lisp_Object *)xmalloc (30 * sizeof (Lisp_Object)); | ||
| 68 | current_kboard->kbd_macro_bufsize = 30; | 67 | current_kboard->kbd_macro_bufsize = 30; |
| 69 | } | 68 | } |
| 70 | update_mode_lines++; | 69 | update_mode_lines++; |
| @@ -205,8 +204,7 @@ store_kbd_macro_char (Lisp_Object c) | |||
| 205 | < kb->kbd_macro_bufsize) | 204 | < kb->kbd_macro_bufsize) |
| 206 | memory_full (SIZE_MAX); | 205 | memory_full (SIZE_MAX); |
| 207 | nbytes = kb->kbd_macro_bufsize * (2 * sizeof *kb->kbd_macro_buffer); | 206 | nbytes = kb->kbd_macro_bufsize * (2 * sizeof *kb->kbd_macro_buffer); |
| 208 | kb->kbd_macro_buffer | 207 | kb->kbd_macro_buffer = xrealloc (kb->kbd_macro_buffer, nbytes); |
| 209 | = (Lisp_Object *) xrealloc (kb->kbd_macro_buffer, nbytes); | ||
| 210 | kb->kbd_macro_bufsize *= 2; | 208 | kb->kbd_macro_bufsize *= 2; |
| 211 | kb->kbd_macro_ptr = kb->kbd_macro_buffer + ptr_offset; | 209 | kb->kbd_macro_ptr = kb->kbd_macro_buffer + ptr_offset; |
| 212 | kb->kbd_macro_end = kb->kbd_macro_buffer + end_offset; | 210 | kb->kbd_macro_end = kb->kbd_macro_buffer + end_offset; |
diff --git a/src/menu.c b/src/menu.c index 598385c38c0..3b8ebb65d2c 100644 --- a/src/menu.c +++ b/src/menu.c | |||
| @@ -632,8 +632,7 @@ digest_single_submenu (int start, int end, int top_level_items) | |||
| 632 | widget_value **submenu_stack; | 632 | widget_value **submenu_stack; |
| 633 | int panes_seen = 0; | 633 | int panes_seen = 0; |
| 634 | 634 | ||
| 635 | submenu_stack | 635 | submenu_stack = alloca (menu_items_used * sizeof *submenu_stack); |
| 636 | = (widget_value **) alloca (menu_items_used * sizeof (widget_value *)); | ||
| 637 | wv = xmalloc_widget_value (); | 636 | wv = xmalloc_widget_value (); |
| 638 | wv->name = "menu"; | 637 | wv->name = "menu"; |
| 639 | wv->value = 0; | 638 | wv->value = 0; |
| @@ -893,7 +892,7 @@ find_and_call_menu_selection (FRAME_PTR f, int menu_bar_items_used, Lisp_Object | |||
| 893 | int i; | 892 | int i; |
| 894 | 893 | ||
| 895 | entry = Qnil; | 894 | entry = Qnil; |
| 896 | subprefix_stack = (Lisp_Object *) alloca (menu_bar_items_used * sizeof (Lisp_Object)); | 895 | subprefix_stack = alloca (menu_bar_items_used * sizeof *subprefix_stack); |
| 897 | prefix = Qnil; | 896 | prefix = Qnil; |
| 898 | i = 0; | 897 | i = 0; |
| 899 | 898 | ||
diff --git a/src/nsfns.m b/src/nsfns.m index cd943ac4bab..5303a5ec313 100644 --- a/src/nsfns.m +++ b/src/nsfns.m | |||
| @@ -1203,8 +1203,7 @@ This function is an internal primitive--use `make-frame' instead. */) | |||
| 1203 | f->terminal = dpyinfo->terminal; | 1203 | f->terminal = dpyinfo->terminal; |
| 1204 | 1204 | ||
| 1205 | f->output_method = output_ns; | 1205 | f->output_method = output_ns; |
| 1206 | f->output_data.ns = (struct ns_output *)xmalloc (sizeof *(f->output_data.ns)); | 1206 | f->output_data.ns = xzalloc (sizeof *f->output_data.ns); |
| 1207 | memset (f->output_data.ns, 0, sizeof *(f->output_data.ns)); | ||
| 1208 | 1207 | ||
| 1209 | FRAME_FONTSET (f) = -1; | 1208 | FRAME_FONTSET (f) = -1; |
| 1210 | 1209 | ||
diff --git a/src/nsfont.m b/src/nsfont.m index 556102b6f44..7a456c4bb5d 100644 --- a/src/nsfont.m +++ b/src/nsfont.m | |||
| @@ -152,7 +152,7 @@ ns_spec_to_descriptor (Lisp_Object font_spec) | |||
| 152 | [fdAttrs setObject: tdict forKey: NSFontTraitsAttribute]; | 152 | [fdAttrs setObject: tdict forKey: NSFontTraitsAttribute]; |
| 153 | 153 | ||
| 154 | fdesc = [NSFontDescriptor fontDescriptorWithFontAttributes: fdAttrs]; | 154 | fdesc = [NSFontDescriptor fontDescriptorWithFontAttributes: fdAttrs]; |
| 155 | if (family != nil) | 155 | if (family != nil) |
| 156 | { | 156 | { |
| 157 | fdesc = [fdesc fontDescriptorWithFamily: family]; | 157 | fdesc = [fdesc fontDescriptorWithFamily: family]; |
| 158 | } | 158 | } |
| @@ -779,14 +779,8 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) | |||
| 779 | if (!font) | 779 | if (!font) |
| 780 | return Qnil; /* FIXME: other terms do, but return Qnil causes segfault */ | 780 | return Qnil; /* FIXME: other terms do, but return Qnil causes segfault */ |
| 781 | 781 | ||
| 782 | font_info->glyphs = (unsigned short **) | 782 | font_info->glyphs = xzalloc (0x100 * sizeof *font_info->glyphs); |
| 783 | xmalloc (0x100 * sizeof (unsigned short *)); | 783 | font_info->metrics = xzalloc (0x100 * sizeof *font_info->metrics); |
| 784 | font_info->metrics = (struct font_metrics **) | ||
| 785 | xmalloc (0x100 * sizeof (struct font_metrics *)); | ||
| 786 | if (!font_info->glyphs || !font_info->metrics) | ||
| 787 | return Qnil; | ||
| 788 | memset (font_info->glyphs, 0, 0x100 * sizeof (unsigned short *)); | ||
| 789 | memset (font_info->metrics, 0, 0x100 * sizeof (struct font_metrics *)); | ||
| 790 | 784 | ||
| 791 | BLOCK_INPUT; | 785 | BLOCK_INPUT; |
| 792 | 786 | ||
| @@ -831,8 +825,7 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) | |||
| 831 | [font_info->nsfont retain]; | 825 | [font_info->nsfont retain]; |
| 832 | 826 | ||
| 833 | /* set up ns_font (defined in nsgui.h) */ | 827 | /* set up ns_font (defined in nsgui.h) */ |
| 834 | font_info->name = (char *)xmalloc (strlen (fontName)+1); | 828 | font_info->name = xstrdup (fontName); |
| 835 | strcpy (font_info->name, fontName); | ||
| 836 | font_info->bold = [fontMgr traitsOfFont: nsfont] & NSBoldFontMask; | 829 | font_info->bold = [fontMgr traitsOfFont: nsfont] & NSBoldFontMask; |
| 837 | font_info->ital = | 830 | font_info->ital = |
| 838 | synthItal || ([fontMgr traitsOfFont: nsfont] & NSItalicFontMask); | 831 | synthItal || ([fontMgr traitsOfFont: nsfont] & NSItalicFontMask); |
| @@ -1371,8 +1364,7 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block) | |||
| 1371 | BLOCK_INPUT; | 1364 | BLOCK_INPUT; |
| 1372 | sfont = [font_info->nsfont screenFont]; | 1365 | sfont = [font_info->nsfont screenFont]; |
| 1373 | 1366 | ||
| 1374 | font_info->metrics[block] = xmalloc (0x100 * sizeof (struct font_metrics)); | 1367 | font_info->metrics[block] = xzalloc (0x100 * sizeof (struct font_metrics)); |
| 1375 | memset (font_info->metrics[block], 0, 0x100 * sizeof (struct font_metrics)); | ||
| 1376 | if (!(font_info->metrics[block])) | 1368 | if (!(font_info->metrics[block])) |
| 1377 | abort (); | 1369 | abort (); |
| 1378 | 1370 | ||
| @@ -1417,7 +1409,7 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block) | |||
| 1417 | maxChar = 0; | 1409 | maxChar = 0; |
| 1418 | maxGlyph = 0; | 1410 | maxGlyph = 0; |
| 1419 | dict = [NSMutableDictionary new]; | 1411 | dict = [NSMutableDictionary new]; |
| 1420 | cglyphs = (CGGlyph *)xmalloc (c * sizeof (CGGlyph)); | 1412 | cglyphs = xmalloc (c * sizeof (CGGlyph)); |
| 1421 | return self; | 1413 | return self; |
| 1422 | } | 1414 | } |
| 1423 | 1415 | ||
diff --git a/src/nsmenu.m b/src/nsmenu.m index 9d74337580a..cccecffb427 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m | |||
| @@ -190,8 +190,7 @@ ns_update_menubar (struct frame *f, int deep_p, EmacsMenu *submenu) | |||
| 190 | ptrdiff_t specpdl_count = SPECPDL_INDEX (); | 190 | ptrdiff_t specpdl_count = SPECPDL_INDEX (); |
| 191 | int previous_menu_items_used = f->menu_bar_items_used; | 191 | int previous_menu_items_used = f->menu_bar_items_used; |
| 192 | Lisp_Object *previous_items | 192 | Lisp_Object *previous_items |
| 193 | = (Lisp_Object *) alloca (previous_menu_items_used | 193 | = alloca (previous_menu_items_used * sizeof *previous_items); |
| 194 | * sizeof (Lisp_Object)); | ||
| 195 | 194 | ||
| 196 | /* lisp preliminaries */ | 195 | /* lisp preliminaries */ |
| 197 | buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer; | 196 | buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer; |
| @@ -231,11 +230,11 @@ ns_update_menubar (struct frame *f, int deep_p, EmacsMenu *submenu) | |||
| 231 | 230 | ||
| 232 | menu_items = f->menu_bar_vector; | 231 | menu_items = f->menu_bar_vector; |
| 233 | menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0; | 232 | menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0; |
| 234 | submenu_start = (int *) alloca (ASIZE (items) * sizeof (int *)); | 233 | submenu_start = alloca (ASIZE (items) * sizeof *submenu_start); |
| 235 | submenu_end = (int *) alloca (ASIZE (items) * sizeof (int *)); | 234 | submenu_end = alloca (ASIZE (items) * sizeof *submenu_end); |
| 236 | submenu_n_panes = (int *) alloca (ASIZE (items) * sizeof (int)); | 235 | submenu_n_panes = alloca (ASIZE (items) * sizeof *submenu_n_panes); |
| 237 | submenu_top_level_items | 236 | submenu_top_level_items = alloca (ASIZE (items) |
| 238 | = (int *) alloca (ASIZE (items) * sizeof (int *)); | 237 | * sizeof *submenu_top_level_items); |
| 239 | init_menu_items (); | 238 | init_menu_items (); |
| 240 | for (i = 0; i < ASIZE (items); i += 4) | 239 | for (i = 0; i < ASIZE (items); i += 4) |
| 241 | { | 240 | { |
| @@ -814,9 +813,9 @@ ns_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, | |||
| 814 | { | 813 | { |
| 815 | widget_value *save_wv = 0, *prev_wv = 0; | 814 | widget_value *save_wv = 0, *prev_wv = 0; |
| 816 | widget_value **submenu_stack | 815 | widget_value **submenu_stack |
| 817 | = (widget_value **) alloca (menu_items_used * sizeof (widget_value *)); | 816 | = alloca (menu_items_used * sizeof *submenu_stack); |
| 818 | /* Lisp_Object *subprefix_stack | 817 | /* Lisp_Object *subprefix_stack |
| 819 | = (Lisp_Object *) alloca (menu_items_used * sizeof (Lisp_Object)); */ | 818 | = alloca (menu_items_used * sizeof *subprefix_stack); */ |
| 820 | int submenu_depth = 0; | 819 | int submenu_depth = 0; |
| 821 | int first_pane = 1; | 820 | int first_pane = 1; |
| 822 | int i; | 821 | int i; |
diff --git a/src/nsterm.m b/src/nsterm.m index 431577c4f01..ae536638c33 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -1323,8 +1323,7 @@ ns_index_color (NSColor *color, struct frame *f) | |||
| 1323 | { | 1323 | { |
| 1324 | color_table->size = NS_COLOR_CAPACITY; | 1324 | color_table->size = NS_COLOR_CAPACITY; |
| 1325 | color_table->avail = 1; /* skip idx=0 as marker */ | 1325 | color_table->avail = 1; /* skip idx=0 as marker */ |
| 1326 | color_table->colors | 1326 | color_table->colors = xmalloc (color_table->size * sizeof (NSColor *)); |
| 1327 | = (NSColor **)xmalloc (color_table->size * sizeof (NSColor *)); | ||
| 1328 | color_table->colors[0] = nil; | 1327 | color_table->colors[0] = nil; |
| 1329 | color_table->empty_indices = [[NSMutableSet alloc] init]; | 1328 | color_table->empty_indices = [[NSMutableSet alloc] init]; |
| 1330 | } | 1329 | } |
| @@ -2245,17 +2244,9 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row, | |||
| 2245 | /* grow bimgs if needed */ | 2244 | /* grow bimgs if needed */ |
| 2246 | if (nBimgs < max_used_fringe_bitmap) | 2245 | if (nBimgs < max_used_fringe_bitmap) |
| 2247 | { | 2246 | { |
| 2248 | EmacsImage **newBimgs | 2247 | bimgs = xrealloc (bimgs, max_used_fringe_bitmap * sizeof *bimgs); |
| 2249 | = xmalloc (max_used_fringe_bitmap * sizeof (EmacsImage *)); | 2248 | memset (bimgs + nBimgs, 0, |
| 2250 | memset (newBimgs, 0, max_used_fringe_bitmap * sizeof (EmacsImage *)); | 2249 | (max_used_fringe_bitmap - nBimgs) * sizeof *bimgs); |
| 2251 | |||
| 2252 | if (nBimgs) | ||
| 2253 | { | ||
| 2254 | memcpy (newBimgs, bimgs, nBimgs * sizeof (EmacsImage *)); | ||
| 2255 | xfree (bimgs); | ||
| 2256 | } | ||
| 2257 | |||
| 2258 | bimgs = newBimgs; | ||
| 2259 | nBimgs = max_used_fringe_bitmap; | 2250 | nBimgs = max_used_fringe_bitmap; |
| 2260 | } | 2251 | } |
| 2261 | 2252 | ||
| @@ -3889,8 +3880,7 @@ ns_initialize_display_info (struct ns_display_info *dpyinfo) | |||
| 3889 | NSColorSpaceFromDepth (depth)]; | 3880 | NSColorSpaceFromDepth (depth)]; |
| 3890 | dpyinfo->n_planes = NSBitsPerPixelFromDepth (depth); | 3881 | dpyinfo->n_planes = NSBitsPerPixelFromDepth (depth); |
| 3891 | dpyinfo->image_cache = make_image_cache (); | 3882 | dpyinfo->image_cache = make_image_cache (); |
| 3892 | dpyinfo->color_table | 3883 | dpyinfo->color_table = xmalloc (sizeof *dpyinfo->color_table); |
| 3893 | = (struct ns_color_table *)xmalloc (sizeof (struct ns_color_table)); | ||
| 3894 | dpyinfo->color_table->colors = NULL; | 3884 | dpyinfo->color_table->colors = NULL; |
| 3895 | dpyinfo->root_window = 42; /* a placeholder.. */ | 3885 | dpyinfo->root_window = 42; /* a placeholder.. */ |
| 3896 | 3886 | ||
| @@ -4071,13 +4061,12 @@ ns_term_init (Lisp_Object display_name) | |||
| 4071 | selector: @selector (logNotification:) | 4061 | selector: @selector (logNotification:) |
| 4072 | name: nil object: nil]; */ | 4062 | name: nil object: nil]; */ |
| 4073 | 4063 | ||
| 4074 | dpyinfo = (struct ns_display_info *)xmalloc (sizeof (struct ns_display_info)); | 4064 | dpyinfo = xzalloc (sizeof *dpyinfo); |
| 4075 | memset (dpyinfo, 0, sizeof (struct ns_display_info)); | ||
| 4076 | 4065 | ||
| 4077 | ns_initialize_display_info (dpyinfo); | 4066 | ns_initialize_display_info (dpyinfo); |
| 4078 | terminal = ns_create_terminal (dpyinfo); | 4067 | terminal = ns_create_terminal (dpyinfo); |
| 4079 | 4068 | ||
| 4080 | terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); | 4069 | terminal->kboard = xmalloc (sizeof *terminal->kboard); |
| 4081 | init_kboard (terminal->kboard); | 4070 | init_kboard (terminal->kboard); |
| 4082 | KVAR (terminal->kboard, Vwindow_system) = Qns; | 4071 | KVAR (terminal->kboard, Vwindow_system) = Qns; |
| 4083 | terminal->kboard->next_kboard = all_kboards; | 4072 | terminal->kboard->next_kboard = all_kboards; |
| @@ -4098,7 +4087,7 @@ ns_term_init (Lisp_Object display_name) | |||
| 4098 | dpyinfo->name_list_element = XCAR (ns_display_name_list); | 4087 | dpyinfo->name_list_element = XCAR (ns_display_name_list); |
| 4099 | 4088 | ||
| 4100 | /* Set the name of the terminal. */ | 4089 | /* Set the name of the terminal. */ |
| 4101 | terminal->name = (char *) xmalloc (SBYTES (display_name) + 1); | 4090 | terminal->name = xmalloc (SBYTES (display_name) + 1); |
| 4102 | strncpy (terminal->name, SDATA (display_name), SBYTES (display_name)); | 4091 | strncpy (terminal->name, SDATA (display_name), SBYTES (display_name)); |
| 4103 | terminal->name[SBYTES (display_name)] = 0; | 4092 | terminal->name[SBYTES (display_name)] = 0; |
| 4104 | 4093 | ||
| @@ -5355,8 +5344,7 @@ ns_term_shutdown (int sig) | |||
| 5355 | char *pos = strstr (t, " — "); | 5344 | char *pos = strstr (t, " — "); |
| 5356 | if (pos) | 5345 | if (pos) |
| 5357 | *pos = '\0'; | 5346 | *pos = '\0'; |
| 5358 | old_title = (char *) xmalloc (strlen (t) + 1); | 5347 | old_title = xstrdup (t); |
| 5359 | strcpy (old_title, t); | ||
| 5360 | } | 5348 | } |
| 5361 | size_title = xmalloc (strlen (old_title) + 40); | 5349 | size_title = xmalloc (strlen (old_title) + 40); |
| 5362 | esprintf (size_title, "%s — (%d x %d)", old_title, cols, rows); | 5350 | esprintf (size_title, "%s — (%d x %d)", old_title, cols, rows); |
| @@ -6076,7 +6064,7 @@ ns_term_shutdown (int sig) | |||
| 6076 | 6064 | ||
| 6077 | if (nr_screens == 1) | 6065 | if (nr_screens == 1) |
| 6078 | return [super constrainFrameRect:frameRect toScreen:screen]; | 6066 | return [super constrainFrameRect:frameRect toScreen:screen]; |
| 6079 | 6067 | ||
| 6080 | if (f->output_data.ns->dont_constrain | 6068 | if (f->output_data.ns->dont_constrain |
| 6081 | || ns_menu_bar_should_be_hidden ()) | 6069 | || ns_menu_bar_should_be_hidden ()) |
| 6082 | return frameRect; | 6070 | return frameRect; |
diff --git a/src/print.c b/src/print.c index b0189b9bc20..b650b1265b1 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -173,8 +173,7 @@ int print_output_debug_flag EXTERNALLY_VISIBLE = 1; | |||
| 173 | if (print_buffer_pos != print_buffer_pos_byte \ | 173 | if (print_buffer_pos != print_buffer_pos_byte \ |
| 174 | && NILP (BVAR (current_buffer, enable_multibyte_characters))) \ | 174 | && NILP (BVAR (current_buffer, enable_multibyte_characters))) \ |
| 175 | { \ | 175 | { \ |
| 176 | unsigned char *temp \ | 176 | unsigned char *temp = alloca (print_buffer_pos + 1); \ |
| 177 | = (unsigned char *) alloca (print_buffer_pos + 1); \ | ||
| 178 | copy_text ((unsigned char *) print_buffer, temp, \ | 177 | copy_text ((unsigned char *) print_buffer, temp, \ |
| 179 | print_buffer_pos_byte, 1, 0); \ | 178 | print_buffer_pos_byte, 1, 0); \ |
| 180 | insert_1_both ((char *) temp, print_buffer_pos, \ | 179 | insert_1_both ((char *) temp, print_buffer_pos, \ |
diff --git a/src/process.c b/src/process.c index 3f329872c76..2cb9e8de15f 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -1365,7 +1365,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) | |||
| 1365 | val = Vcoding_system_for_read; | 1365 | val = Vcoding_system_for_read; |
| 1366 | if (NILP (val)) | 1366 | if (NILP (val)) |
| 1367 | { | 1367 | { |
| 1368 | args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2); | 1368 | args2 = alloca ((nargs + 1) * sizeof *args2); |
| 1369 | args2[0] = Qstart_process; | 1369 | args2[0] = Qstart_process; |
| 1370 | for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; | 1370 | for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; |
| 1371 | GCPRO2 (proc, current_dir); | 1371 | GCPRO2 (proc, current_dir); |
| @@ -1384,7 +1384,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) | |||
| 1384 | { | 1384 | { |
| 1385 | if (EQ (coding_systems, Qt)) | 1385 | if (EQ (coding_systems, Qt)) |
| 1386 | { | 1386 | { |
| 1387 | args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2); | 1387 | args2 = alloca ((nargs + 1) * sizeof *args2); |
| 1388 | args2[0] = Qstart_process; | 1388 | args2[0] = Qstart_process; |
| 1389 | for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; | 1389 | for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; |
| 1390 | GCPRO2 (proc, current_dir); | 1390 | GCPRO2 (proc, current_dir); |
| @@ -1478,7 +1478,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) | |||
| 1478 | 1478 | ||
| 1479 | /* Now that everything is encoded we can collect the strings into | 1479 | /* Now that everything is encoded we can collect the strings into |
| 1480 | NEW_ARGV. */ | 1480 | NEW_ARGV. */ |
| 1481 | new_argv = (unsigned char **) alloca ((nargs - 1) * sizeof (char *)); | 1481 | new_argv = alloca ((nargs - 1) * sizeof *new_argv); |
| 1482 | new_argv[nargs - 2] = 0; | 1482 | new_argv[nargs - 2] = 0; |
| 1483 | 1483 | ||
| 1484 | for (i = nargs - 2; i-- != 0; ) | 1484 | for (i = nargs - 2; i-- != 0; ) |
| @@ -5037,7 +5037,7 @@ read_process_output (Lisp_Object proc, register int channel) | |||
| 5037 | ptrdiff_t count = SPECPDL_INDEX (); | 5037 | ptrdiff_t count = SPECPDL_INDEX (); |
| 5038 | Lisp_Object odeactivate; | 5038 | Lisp_Object odeactivate; |
| 5039 | 5039 | ||
| 5040 | chars = (char *) alloca (carryover + readmax); | 5040 | chars = alloca (carryover + readmax); |
| 5041 | if (carryover) | 5041 | if (carryover) |
| 5042 | /* See the comment above. */ | 5042 | /* See the comment above. */ |
| 5043 | memcpy (chars, SDATA (p->decoding_buf), carryover); | 5043 | memcpy (chars, SDATA (p->decoding_buf), carryover); |
| @@ -7083,8 +7083,7 @@ setup_process_coding_systems (Lisp_Object process) | |||
| 7083 | return; | 7083 | return; |
| 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] = xmalloc (sizeof (struct coding_system)); |
| 7087 | = xmalloc (sizeof (struct coding_system)); | ||
| 7088 | coding_system = p->decode_coding_system; | 7087 | coding_system = p->decode_coding_system; |
| 7089 | if (! NILP (p->filter)) | 7088 | if (! NILP (p->filter)) |
| 7090 | ; | 7089 | ; |
| @@ -7096,8 +7095,7 @@ setup_process_coding_systems (Lisp_Object process) | |||
| 7096 | setup_coding_system (coding_system, proc_decode_coding_system[inch]); | 7095 | setup_coding_system (coding_system, proc_decode_coding_system[inch]); |
| 7097 | 7096 | ||
| 7098 | if (!proc_encode_coding_system[outch]) | 7097 | if (!proc_encode_coding_system[outch]) |
| 7099 | proc_encode_coding_system[outch] | 7098 | proc_encode_coding_system[outch] = xmalloc (sizeof (struct coding_system)); |
| 7100 | = xmalloc (sizeof (struct coding_system)); | ||
| 7101 | setup_coding_system (p->encode_coding_system, | 7099 | setup_coding_system (p->encode_coding_system, |
| 7102 | proc_encode_coding_system[outch]); | 7100 | proc_encode_coding_system[outch]); |
| 7103 | #endif | 7101 | #endif |
diff --git a/src/ralloc.c b/src/ralloc.c index 0d8bcaf4ffb..c40258693f5 100644 --- a/src/ralloc.c +++ b/src/ralloc.c | |||
| @@ -396,7 +396,7 @@ get_bloc (SIZE size) | |||
| 396 | register bloc_ptr new_bloc; | 396 | register bloc_ptr new_bloc; |
| 397 | register heap_ptr heap; | 397 | register heap_ptr heap; |
| 398 | 398 | ||
| 399 | if (! (new_bloc = (bloc_ptr) malloc (BLOC_PTR_SIZE)) | 399 | if (! (new_bloc = malloc (BLOC_PTR_SIZE)) |
| 400 | || ! (new_bloc->data = obtain (break_value, size))) | 400 | || ! (new_bloc->data = obtain (break_value, size))) |
| 401 | { | 401 | { |
| 402 | free (new_bloc); | 402 | free (new_bloc); |
diff --git a/src/regex.c b/src/regex.c index f3f70060b2e..751006d57ba 100644 --- a/src/regex.c +++ b/src/regex.c | |||
| @@ -212,8 +212,7 @@ | |||
| 212 | static void * | 212 | static void * |
| 213 | xmalloc (size_t size) | 213 | xmalloc (size_t size) |
| 214 | { | 214 | { |
| 215 | register void *val; | 215 | void *val = malloc (size); |
| 216 | val = (void *) malloc (size); | ||
| 217 | if (!val && size) | 216 | if (!val && size) |
| 218 | { | 217 | { |
| 219 | write (2, "virtual memory exhausted\n", 25); | 218 | write (2, "virtual memory exhausted\n", 25); |
| @@ -225,13 +224,13 @@ xmalloc (size_t size) | |||
| 225 | static void * | 224 | static void * |
| 226 | xrealloc (void *block, size_t size) | 225 | xrealloc (void *block, size_t size) |
| 227 | { | 226 | { |
| 228 | register void *val; | 227 | void *val; |
| 229 | /* We must call malloc explicitly when BLOCK is 0, since some | 228 | /* We must call malloc explicitly when BLOCK is 0, since some |
| 230 | reallocs don't do this. */ | 229 | reallocs don't do this. */ |
| 231 | if (! block) | 230 | if (! block) |
| 232 | val = (void *) malloc (size); | 231 | val = malloc (size); |
| 233 | else | 232 | else |
| 234 | val = (void *) realloc (block, size); | 233 | val = realloc (block, size); |
| 235 | if (!val && size) | 234 | if (!val && size) |
| 236 | { | 235 | { |
| 237 | write (2, "virtual memory exhausted\n", 25); | 236 | write (2, "virtual memory exhausted\n", 25); |
| @@ -1386,7 +1385,7 @@ typedef struct | |||
| 1386 | #ifdef MATCH_MAY_ALLOCATE | 1385 | #ifdef MATCH_MAY_ALLOCATE |
| 1387 | # define INIT_FAIL_STACK() \ | 1386 | # define INIT_FAIL_STACK() \ |
| 1388 | do { \ | 1387 | do { \ |
| 1389 | fail_stack.stack = (fail_stack_elt_t *) \ | 1388 | fail_stack.stack = \ |
| 1390 | REGEX_ALLOCATE_STACK (INIT_FAILURE_ALLOC * TYPICAL_FAILURE_SIZE \ | 1389 | REGEX_ALLOCATE_STACK (INIT_FAILURE_ALLOC * TYPICAL_FAILURE_SIZE \ |
| 1391 | * sizeof (fail_stack_elt_t)); \ | 1390 | * sizeof (fail_stack_elt_t)); \ |
| 1392 | \ | 1391 | \ |
| @@ -1429,8 +1428,7 @@ typedef struct | |||
| 1429 | >= re_max_failures * TYPICAL_FAILURE_SIZE) \ | 1428 | >= re_max_failures * TYPICAL_FAILURE_SIZE) \ |
| 1430 | ? 0 \ | 1429 | ? 0 \ |
| 1431 | : ((fail_stack).stack \ | 1430 | : ((fail_stack).stack \ |
| 1432 | = (fail_stack_elt_t *) \ | 1431 | = REGEX_REALLOCATE_STACK ((fail_stack).stack, \ |
| 1433 | REGEX_REALLOCATE_STACK ((fail_stack).stack, \ | ||
| 1434 | (fail_stack).size * sizeof (fail_stack_elt_t), \ | 1432 | (fail_stack).size * sizeof (fail_stack_elt_t), \ |
| 1435 | MIN (re_max_failures * TYPICAL_FAILURE_SIZE, \ | 1433 | MIN (re_max_failures * TYPICAL_FAILURE_SIZE, \ |
| 1436 | ((fail_stack).size * sizeof (fail_stack_elt_t) \ | 1434 | ((fail_stack).size * sizeof (fail_stack_elt_t) \ |
| @@ -2141,12 +2139,7 @@ static void | |||
| 2141 | extend_range_table_work_area (struct range_table_work_area *work_area) | 2139 | extend_range_table_work_area (struct range_table_work_area *work_area) |
| 2142 | { | 2140 | { |
| 2143 | work_area->allocated += 16 * sizeof (int); | 2141 | work_area->allocated += 16 * sizeof (int); |
| 2144 | if (work_area->table) | 2142 | work_area->table = realloc (work_area->table, work_area->allocated); |
| 2145 | work_area->table | ||
| 2146 | = (int *) realloc (work_area->table, work_area->allocated); | ||
| 2147 | else | ||
| 2148 | work_area->table | ||
| 2149 | = (int *) malloc (work_area->allocated); | ||
| 2150 | } | 2143 | } |
| 2151 | 2144 | ||
| 2152 | #if 0 | 2145 | #if 0 |
| @@ -3741,16 +3734,8 @@ regex_compile (const re_char *pattern, size_t size, reg_syntax_t syntax, struct | |||
| 3741 | if (fail_stack.size < re_max_failures * TYPICAL_FAILURE_SIZE) | 3734 | if (fail_stack.size < re_max_failures * TYPICAL_FAILURE_SIZE) |
| 3742 | { | 3735 | { |
| 3743 | fail_stack.size = re_max_failures * TYPICAL_FAILURE_SIZE; | 3736 | fail_stack.size = re_max_failures * TYPICAL_FAILURE_SIZE; |
| 3744 | 3737 | falk_stack.stack = realloc (fail_stack.stack, | |
| 3745 | if (! fail_stack.stack) | 3738 | fail_stack.size * sizeof *falk_stack.stack); |
| 3746 | fail_stack.stack | ||
| 3747 | = (fail_stack_elt_t *) malloc (fail_stack.size | ||
| 3748 | * sizeof (fail_stack_elt_t)); | ||
| 3749 | else | ||
| 3750 | fail_stack.stack | ||
| 3751 | = (fail_stack_elt_t *) realloc (fail_stack.stack, | ||
| 3752 | (fail_stack.size | ||
| 3753 | * sizeof (fail_stack_elt_t))); | ||
| 3754 | } | 3739 | } |
| 3755 | 3740 | ||
| 3756 | regex_grow_registers (num_regs); | 3741 | regex_grow_registers (num_regs); |
| @@ -6408,13 +6393,13 @@ re_comp (const char *s) | |||
| 6408 | 6393 | ||
| 6409 | if (!re_comp_buf.buffer) | 6394 | if (!re_comp_buf.buffer) |
| 6410 | { | 6395 | { |
| 6411 | re_comp_buf.buffer = (unsigned char *) malloc (200); | 6396 | re_comp_buf.buffer = malloc (200); |
| 6412 | if (re_comp_buf.buffer == NULL) | 6397 | if (re_comp_buf.buffer == NULL) |
| 6413 | /* Yes, we're discarding `const' here if !HAVE_LIBINTL. */ | 6398 | /* Yes, we're discarding `const' here if !HAVE_LIBINTL. */ |
| 6414 | return (char *) gettext (re_error_msgid[(int) REG_ESPACE]); | 6399 | return (char *) gettext (re_error_msgid[(int) REG_ESPACE]); |
| 6415 | re_comp_buf.allocated = 200; | 6400 | re_comp_buf.allocated = 200; |
| 6416 | 6401 | ||
| 6417 | re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH); | 6402 | re_comp_buf.fastmap = malloc (1 << BYTEWIDTH); |
| 6418 | if (re_comp_buf.fastmap == NULL) | 6403 | if (re_comp_buf.fastmap == NULL) |
| 6419 | /* Yes, we're discarding `const' here if !HAVE_LIBINTL. */ | 6404 | /* Yes, we're discarding `const' here if !HAVE_LIBINTL. */ |
| 6420 | return (char *) gettext (re_error_msgid[(int) REG_ESPACE]); | 6405 | return (char *) gettext (re_error_msgid[(int) REG_ESPACE]); |
| @@ -6498,15 +6483,13 @@ regcomp (regex_t *__restrict preg, const char *__restrict pattern, | |||
| 6498 | preg->used = 0; | 6483 | preg->used = 0; |
| 6499 | 6484 | ||
| 6500 | /* Try to allocate space for the fastmap. */ | 6485 | /* Try to allocate space for the fastmap. */ |
| 6501 | preg->fastmap = (char *) malloc (1 << BYTEWIDTH); | 6486 | preg->fastmap = malloc (1 << BYTEWIDTH); |
| 6502 | 6487 | ||
| 6503 | if (cflags & REG_ICASE) | 6488 | if (cflags & REG_ICASE) |
| 6504 | { | 6489 | { |
| 6505 | unsigned i; | 6490 | unsigned i; |
| 6506 | 6491 | ||
| 6507 | preg->translate | 6492 | preg->translate = malloc (CHAR_SET_SIZE * sizeof *preg->translate); |
| 6508 | = (RE_TRANSLATE_TYPE) malloc (CHAR_SET_SIZE | ||
| 6509 | * sizeof (*(RE_TRANSLATE_TYPE)0)); | ||
| 6510 | if (preg->translate == NULL) | 6493 | if (preg->translate == NULL) |
| 6511 | return (int) REG_ESPACE; | 6494 | return (int) REG_ESPACE; |
| 6512 | 6495 | ||
diff --git a/src/region-cache.c b/src/region-cache.c index a3a2a072c8c..14b6233a5a5 100644 --- a/src/region-cache.c +++ b/src/region-cache.c | |||
| @@ -132,7 +132,7 @@ 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 = xmalloc (sizeof (struct region_cache)); | 135 | struct region_cache *c = xmalloc (sizeof *c); |
| 136 | 136 | ||
| 137 | c->gap_start = 0; | 137 | c->gap_start = 0; |
| 138 | c->gap_len = NEW_CACHE_GAP; | 138 | c->gap_len = NEW_CACHE_GAP; |
diff --git a/src/scroll.c b/src/scroll.c index 86d775545b0..78ebe65bdcc 100644 --- a/src/scroll.c +++ b/src/scroll.c | |||
| @@ -253,11 +253,11 @@ do_scrolling (struct frame *frame, struct glyph_matrix *current_matrix, | |||
| 253 | /* A queue for line insertions to be done. */ | 253 | /* A queue for line insertions to be done. */ |
| 254 | struct queue { int count, pos; }; | 254 | struct queue { int count, pos; }; |
| 255 | struct queue *queue_start | 255 | struct queue *queue_start |
| 256 | = (struct queue *) alloca (current_matrix->nrows * sizeof (struct queue)); | 256 | = alloca (current_matrix->nrows * sizeof *queue_start); |
| 257 | struct queue *queue = queue_start; | 257 | struct queue *queue = queue_start; |
| 258 | 258 | ||
| 259 | char *retained_p = (char *) alloca (window_size * sizeof (char)); | 259 | char *retained_p = alloca (window_size * sizeof *retained_p); |
| 260 | int *copy_from = (int *) alloca (window_size * sizeof (int)); | 260 | int *copy_from = alloca (window_size * sizeof *copy_from); |
| 261 | 261 | ||
| 262 | /* Zero means line is empty. */ | 262 | /* Zero means line is empty. */ |
| 263 | memset (retained_p, 0, window_size * sizeof (char)); | 263 | memset (retained_p, 0, window_size * sizeof (char)); |
| @@ -671,11 +671,11 @@ do_direct_scrolling (struct frame *frame, struct glyph_matrix *current_matrix, | |||
| 671 | int write_follows_p = 1; | 671 | int write_follows_p = 1; |
| 672 | 672 | ||
| 673 | /* For each row in the new matrix what row of the old matrix it is. */ | 673 | /* For each row in the new matrix what row of the old matrix it is. */ |
| 674 | int *copy_from = (int *) alloca (window_size * sizeof (int)); | 674 | int *copy_from = alloca (window_size * sizeof *copy_from); |
| 675 | 675 | ||
| 676 | /* Non-zero for each row in the new matrix that is retained from the | 676 | /* Non-zero for each row in the new matrix that is retained from the |
| 677 | old matrix. Lines not retained are empty. */ | 677 | old matrix. Lines not retained are empty. */ |
| 678 | char *retained_p = (char *) alloca (window_size * sizeof (char)); | 678 | char *retained_p = alloca (window_size * sizeof *retained_p); |
| 679 | 679 | ||
| 680 | memset (retained_p, 0, window_size * sizeof (char)); | 680 | memset (retained_p, 0, window_size * sizeof (char)); |
| 681 | 681 | ||
diff --git a/src/search.c b/src/search.c index a7ea3634579..9004dc78271 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -175,8 +175,7 @@ shrink_regexp_cache (void) | |||
| 175 | for (cp = searchbuf_head; cp != 0; cp = cp->next) | 175 | for (cp = searchbuf_head; cp != 0; cp = cp->next) |
| 176 | { | 176 | { |
| 177 | cp->buf.allocated = cp->buf.used; | 177 | cp->buf.allocated = cp->buf.used; |
| 178 | cp->buf.buffer | 178 | cp->buf.buffer = xrealloc (cp->buf.buffer, cp->buf.used); |
| 179 | = (unsigned char *) xrealloc (cp->buf.buffer, cp->buf.used); | ||
| 180 | } | 179 | } |
| 181 | } | 180 | } |
| 182 | 181 | ||
| @@ -1274,7 +1273,7 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, | |||
| 1274 | raw_pattern_size_byte | 1273 | raw_pattern_size_byte |
| 1275 | = count_size_as_multibyte (SDATA (string), | 1274 | = count_size_as_multibyte (SDATA (string), |
| 1276 | raw_pattern_size); | 1275 | raw_pattern_size); |
| 1277 | raw_pattern = (unsigned char *) alloca (raw_pattern_size_byte + 1); | 1276 | raw_pattern = alloca (raw_pattern_size_byte + 1); |
| 1278 | copy_text (SDATA (string), raw_pattern, | 1277 | copy_text (SDATA (string), raw_pattern, |
| 1279 | SCHARS (string), 0, 1); | 1278 | SCHARS (string), 0, 1); |
| 1280 | } | 1279 | } |
| @@ -1288,7 +1287,7 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, | |||
| 1288 | the chosen single-byte character set can possibly match. */ | 1287 | the chosen single-byte character set can possibly match. */ |
| 1289 | raw_pattern_size = SCHARS (string); | 1288 | raw_pattern_size = SCHARS (string); |
| 1290 | raw_pattern_size_byte = SCHARS (string); | 1289 | raw_pattern_size_byte = SCHARS (string); |
| 1291 | raw_pattern = (unsigned char *) alloca (raw_pattern_size + 1); | 1290 | raw_pattern = alloca (raw_pattern_size + 1); |
| 1292 | copy_text (SDATA (string), raw_pattern, | 1291 | copy_text (SDATA (string), raw_pattern, |
| 1293 | SBYTES (string), 1, 0); | 1292 | SBYTES (string), 1, 0); |
| 1294 | } | 1293 | } |
| @@ -1296,7 +1295,7 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, | |||
| 1296 | /* Copy and optionally translate the pattern. */ | 1295 | /* Copy and optionally translate the pattern. */ |
| 1297 | len = raw_pattern_size; | 1296 | len = raw_pattern_size; |
| 1298 | len_byte = raw_pattern_size_byte; | 1297 | len_byte = raw_pattern_size_byte; |
| 1299 | patbuf = (unsigned char *) alloca (len * MAX_MULTIBYTE_LENGTH); | 1298 | patbuf = alloca (len * MAX_MULTIBYTE_LENGTH); |
| 1300 | pat = patbuf; | 1299 | pat = patbuf; |
| 1301 | base_pat = raw_pattern; | 1300 | base_pat = raw_pattern; |
| 1302 | if (multibyte) | 1301 | if (multibyte) |
| @@ -2741,8 +2740,7 @@ Return value is undefined if the last search failed. */) | |||
| 2741 | 2740 | ||
| 2742 | prev = Qnil; | 2741 | prev = Qnil; |
| 2743 | 2742 | ||
| 2744 | data = (Lisp_Object *) alloca ((2 * search_regs.num_regs + 1) | 2743 | data = alloca ((2 * search_regs.num_regs + 1) * sizeof *data); |
| 2745 | * sizeof (Lisp_Object)); | ||
| 2746 | 2744 | ||
| 2747 | len = 0; | 2745 | len = 0; |
| 2748 | for (i = 0; i < search_regs.num_regs; i++) | 2746 | for (i = 0; i < search_regs.num_regs; i++) |
| @@ -3008,7 +3006,7 @@ DEFUN ("regexp-quote", Fregexp_quote, Sregexp_quote, 1, 1, 0, | |||
| 3008 | 3006 | ||
| 3009 | CHECK_STRING (string); | 3007 | CHECK_STRING (string); |
| 3010 | 3008 | ||
| 3011 | temp = (char *) alloca (SBYTES (string) * 2); | 3009 | temp = alloca (SBYTES (string) * 2); |
| 3012 | 3010 | ||
| 3013 | /* Now copy the data into the new string, inserting escapes. */ | 3011 | /* Now copy the data into the new string, inserting escapes. */ |
| 3014 | 3012 | ||
diff --git a/src/sound.c b/src/sound.c index e28e8c69f11..adeb3c47f0f 100644 --- a/src/sound.c +++ b/src/sound.c | |||
| @@ -594,7 +594,7 @@ wav_play (struct sound *s, struct sound_device *sd) | |||
| 594 | ptrdiff_t blksize = sd->period_size ? sd->period_size (sd) : 2048; | 594 | ptrdiff_t blksize = sd->period_size ? sd->period_size (sd) : 2048; |
| 595 | ptrdiff_t data_left = header->data_length; | 595 | ptrdiff_t data_left = header->data_length; |
| 596 | 596 | ||
| 597 | buffer = (char *) alloca (blksize); | 597 | buffer = alloca (blksize); |
| 598 | lseek (s->fd, sizeof *header, SEEK_SET); | 598 | lseek (s->fd, sizeof *header, SEEK_SET); |
| 599 | while (data_left > 0 | 599 | while (data_left > 0 |
| 600 | && (nbytes = emacs_read (s->fd, buffer, blksize)) > 0) | 600 | && (nbytes = emacs_read (s->fd, buffer, blksize)) > 0) |
| @@ -688,7 +688,7 @@ au_play (struct sound *s, struct sound_device *sd) | |||
| 688 | lseek (s->fd, header->data_offset, SEEK_SET); | 688 | lseek (s->fd, header->data_offset, SEEK_SET); |
| 689 | 689 | ||
| 690 | /* Copy sound data to the device. */ | 690 | /* Copy sound data to the device. */ |
| 691 | buffer = (char *) alloca (blksize); | 691 | buffer = alloca (blksize); |
| 692 | while ((nbytes = emacs_read (s->fd, buffer, blksize)) > 0) | 692 | while ((nbytes = emacs_read (s->fd, buffer, blksize)) > 0) |
| 693 | sd->write (sd, buffer, nbytes); | 693 | sd->write (sd, buffer, nbytes); |
| 694 | 694 | ||
| @@ -932,7 +932,7 @@ alsa_open (struct sound_device *sd) | |||
| 932 | else | 932 | else |
| 933 | file = DEFAULT_ALSA_SOUND_DEVICE; | 933 | file = DEFAULT_ALSA_SOUND_DEVICE; |
| 934 | 934 | ||
| 935 | p = xmalloc (sizeof (*p)); | 935 | p = xmalloc (sizeof *p); |
| 936 | p->handle = NULL; | 936 | p->handle = NULL; |
| 937 | p->hwparams = NULL; | 937 | p->hwparams = NULL; |
| 938 | p->swparams = NULL; | 938 | p->swparams = NULL; |
| @@ -1364,10 +1364,10 @@ 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 = xzalloc (sizeof (struct sound_device)); | 1367 | current_sound_device = xzalloc (sizeof *current_sound_device); |
| 1368 | current_sound = xzalloc (sizeof (struct sound)); | 1368 | current_sound = xzalloc (sizeof *current_sound); |
| 1369 | record_unwind_protect (sound_cleanup, Qnil); | 1369 | record_unwind_protect (sound_cleanup, Qnil); |
| 1370 | current_sound->header = (char *) alloca (MAX_SOUND_HEADER_BYTES); | 1370 | current_sound->header = alloca (MAX_SOUND_HEADER_BYTES); |
| 1371 | 1371 | ||
| 1372 | if (STRINGP (attrs[SOUND_FILE])) | 1372 | if (STRINGP (attrs[SOUND_FILE])) |
| 1373 | { | 1373 | { |
| @@ -1399,7 +1399,7 @@ Internal use only, use `play-sound' instead. */) | |||
| 1399 | if (STRINGP (attrs[SOUND_DEVICE])) | 1399 | if (STRINGP (attrs[SOUND_DEVICE])) |
| 1400 | { | 1400 | { |
| 1401 | int len = SCHARS (attrs[SOUND_DEVICE]); | 1401 | int len = SCHARS (attrs[SOUND_DEVICE]); |
| 1402 | current_sound_device->file = (char *) alloca (len + 1); | 1402 | current_sound_device->file = alloca (len + 1); |
| 1403 | strcpy (current_sound_device->file, SSDATA (attrs[SOUND_DEVICE])); | 1403 | strcpy (current_sound_device->file, SSDATA (attrs[SOUND_DEVICE])); |
| 1404 | } | 1404 | } |
| 1405 | 1405 | ||
| @@ -1431,7 +1431,7 @@ Internal use only, use `play-sound' instead. */) | |||
| 1431 | 1431 | ||
| 1432 | lo_file = Fexpand_file_name (attrs[SOUND_FILE], Qnil); | 1432 | lo_file = Fexpand_file_name (attrs[SOUND_FILE], Qnil); |
| 1433 | len = XSTRING (lo_file)->size; | 1433 | len = XSTRING (lo_file)->size; |
| 1434 | psz_file = (char *) alloca (len + 1); | 1434 | psz_file = alloca (len + 1); |
| 1435 | strcpy (psz_file, XSTRING (lo_file)->data); | 1435 | strcpy (psz_file, XSTRING (lo_file)->data); |
| 1436 | if (INTEGERP (attrs[SOUND_VOLUME])) | 1436 | if (INTEGERP (attrs[SOUND_VOLUME])) |
| 1437 | { | 1437 | { |
diff --git a/src/syntax.c b/src/syntax.c index e7e68e23744..de1ab2a7516 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -1581,7 +1581,7 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl | |||
| 1581 | fastmap[CHAR_LEADING_CODE (c)] = 1; | 1581 | fastmap[CHAR_LEADING_CODE (c)] = 1; |
| 1582 | range_start_byte = i; | 1582 | range_start_byte = i; |
| 1583 | range_start_char = c; | 1583 | range_start_char = c; |
| 1584 | char_ranges = (int *) alloca (sizeof (int) * 128 * 2); | 1584 | char_ranges = alloca (sizeof *char_ranges * 128 * 2); |
| 1585 | for (i = 129; i < 0400; i++) | 1585 | for (i = 129; i < 0400; i++) |
| 1586 | { | 1586 | { |
| 1587 | c = BYTE8_TO_CHAR (i); | 1587 | c = BYTE8_TO_CHAR (i); |
| @@ -1602,7 +1602,7 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl | |||
| 1602 | } | 1602 | } |
| 1603 | else /* STRING is multibyte */ | 1603 | else /* STRING is multibyte */ |
| 1604 | { | 1604 | { |
| 1605 | char_ranges = (int *) alloca (sizeof (int) * SCHARS (string) * 2); | 1605 | char_ranges = alloca (sizeof *char_ranges * SCHARS (string) * 2); |
| 1606 | 1606 | ||
| 1607 | while (i_byte < size_byte) | 1607 | while (i_byte < size_byte) |
| 1608 | { | 1608 | { |
diff --git a/src/sysdep.c b/src/sysdep.c index afab85439f3..7a4fa9aa5f7 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -143,7 +143,7 @@ get_current_dir_name (void) | |||
| 143 | #endif | 143 | #endif |
| 144 | ) | 144 | ) |
| 145 | { | 145 | { |
| 146 | buf = (char *) malloc (strlen (pwd) + 1); | 146 | buf = malloc (strlen (pwd) + 1); |
| 147 | if (!buf) | 147 | if (!buf) |
| 148 | return NULL; | 148 | return NULL; |
| 149 | strcpy (buf, pwd); | 149 | strcpy (buf, pwd); |
| @@ -152,7 +152,7 @@ get_current_dir_name (void) | |||
| 152 | else | 152 | else |
| 153 | { | 153 | { |
| 154 | size_t buf_size = 1024; | 154 | size_t buf_size = 1024; |
| 155 | buf = (char *) malloc (buf_size); | 155 | buf = malloc (buf_size); |
| 156 | if (!buf) | 156 | if (!buf) |
| 157 | return NULL; | 157 | return NULL; |
| 158 | for (;;) | 158 | for (;;) |
| @@ -167,7 +167,7 @@ get_current_dir_name (void) | |||
| 167 | return NULL; | 167 | return NULL; |
| 168 | } | 168 | } |
| 169 | buf_size *= 2; | 169 | buf_size *= 2; |
| 170 | buf = (char *) realloc (buf, buf_size); | 170 | buf = realloc (buf, buf_size); |
| 171 | if (!buf) | 171 | if (!buf) |
| 172 | return NULL; | 172 | return NULL; |
| 173 | } | 173 | } |
| @@ -176,7 +176,7 @@ get_current_dir_name (void) | |||
| 176 | else | 176 | else |
| 177 | { | 177 | { |
| 178 | /* We need MAXPATHLEN here. */ | 178 | /* We need MAXPATHLEN here. */ |
| 179 | buf = (char *) malloc (MAXPATHLEN + 1); | 179 | buf = malloc (MAXPATHLEN + 1); |
| 180 | if (!buf) | 180 | if (!buf) |
| 181 | return NULL; | 181 | return NULL; |
| 182 | if (getwd (buf) == NULL) | 182 | if (getwd (buf) == NULL) |
| @@ -516,7 +516,7 @@ sys_subshell (void) | |||
| 516 | goto xyzzy; | 516 | goto xyzzy; |
| 517 | 517 | ||
| 518 | dir = expand_and_dir_to_file (Funhandled_file_name_directory (dir), Qnil); | 518 | dir = expand_and_dir_to_file (Funhandled_file_name_directory (dir), Qnil); |
| 519 | str_volatile = str = (unsigned char *) alloca (SCHARS (dir) + 2); | 519 | str_volatile = str = alloca (SCHARS (dir) + 2); |
| 520 | len = SCHARS (dir); | 520 | len = SCHARS (dir); |
| 521 | memcpy (str, SDATA (dir), len); | 521 | memcpy (str, SDATA (dir), len); |
| 522 | if (str[len - 1] != '/') str[len++] = '/'; | 522 | if (str[len - 1] != '/') str[len++] = '/'; |
| @@ -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 = xmalloc (sizeof (struct emacs_tty)); | 854 | tty_out->old_tty = xmalloc (sizeof *tty_out->old_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 | ||
| @@ -1345,7 +1345,7 @@ init_system_name (void) | |||
| 1345 | Vsystem_name = build_string (uts.nodename); | 1345 | Vsystem_name = build_string (uts.nodename); |
| 1346 | #else /* HAVE_GETHOSTNAME */ | 1346 | #else /* HAVE_GETHOSTNAME */ |
| 1347 | unsigned int hostname_size = 256; | 1347 | unsigned int hostname_size = 256; |
| 1348 | char *hostname = (char *) alloca (hostname_size); | 1348 | char *hostname = alloca (hostname_size); |
| 1349 | 1349 | ||
| 1350 | /* Try to get the host name; if the buffer is too short, try | 1350 | /* Try to get the host name; if the buffer is too short, try |
| 1351 | again. Apparently, the only indication gethostname gives of | 1351 | again. Apparently, the only indication gethostname gives of |
| @@ -1361,7 +1361,7 @@ init_system_name (void) | |||
| 1361 | break; | 1361 | break; |
| 1362 | 1362 | ||
| 1363 | hostname_size <<= 1; | 1363 | hostname_size <<= 1; |
| 1364 | hostname = (char *) alloca (hostname_size); | 1364 | hostname = alloca (hostname_size); |
| 1365 | } | 1365 | } |
| 1366 | #ifdef HAVE_SOCKETS | 1366 | #ifdef HAVE_SOCKETS |
| 1367 | /* Turn the hostname into the official, fully-qualified hostname. | 1367 | /* Turn the hostname into the official, fully-qualified hostname. |
diff --git a/src/term.c b/src/term.c index ebf2f0b341e..5e48cbbfc64 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -2858,13 +2858,11 @@ DEFUN ("gpm-mouse-stop", Fgpm_mouse_stop, Sgpm_mouse_stop, | |||
| 2858 | void | 2858 | void |
| 2859 | create_tty_output (struct frame *f) | 2859 | create_tty_output (struct frame *f) |
| 2860 | { | 2860 | { |
| 2861 | struct tty_output *t; | 2861 | struct tty_output *t = xzalloc (sizeof *t); |
| 2862 | 2862 | ||
| 2863 | if (! FRAME_TERMCAP_P (f)) | 2863 | if (! FRAME_TERMCAP_P (f)) |
| 2864 | abort (); | 2864 | abort (); |
| 2865 | 2865 | ||
| 2866 | t = xzalloc (sizeof (struct tty_output)); | ||
| 2867 | |||
| 2868 | t->display_info = FRAME_TERMINAL (f)->display_info.tty; | 2866 | t->display_info = FRAME_TERMINAL (f)->display_info.tty; |
| 2869 | 2867 | ||
| 2870 | f->output_data.tty = t; | 2868 | f->output_data.tty = t; |
| @@ -3064,7 +3062,7 @@ init_tty (const char *name, const char *terminal_type, int must_succeed) | |||
| 3064 | been_here = 1; | 3062 | been_here = 1; |
| 3065 | tty = &the_only_display_info; | 3063 | tty = &the_only_display_info; |
| 3066 | #else | 3064 | #else |
| 3067 | tty = xzalloc (sizeof (struct tty_display_info)); | 3065 | tty = xzalloc (sizeof *tty); |
| 3068 | #endif | 3066 | #endif |
| 3069 | tty->next = tty_list; | 3067 | tty->next = tty_list; |
| 3070 | tty_list = tty; | 3068 | tty_list = tty; |
| @@ -3073,7 +3071,7 @@ init_tty (const char *name, const char *terminal_type, int must_succeed) | |||
| 3073 | terminal->display_info.tty = tty; | 3071 | terminal->display_info.tty = tty; |
| 3074 | tty->terminal = terminal; | 3072 | tty->terminal = terminal; |
| 3075 | 3073 | ||
| 3076 | tty->Wcm = xmalloc (sizeof (struct cm)); | 3074 | tty->Wcm = xmalloc (sizeof *tty->Wcm); |
| 3077 | Wcm_clear (tty); | 3075 | Wcm_clear (tty); |
| 3078 | 3076 | ||
| 3079 | encode_terminal_src_size = 0; | 3077 | encode_terminal_src_size = 0; |
| @@ -3343,7 +3341,7 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ | |||
| 3343 | tty->mouse_highlight.mouse_face_window = Qnil; | 3341 | tty->mouse_highlight.mouse_face_window = Qnil; |
| 3344 | #endif | 3342 | #endif |
| 3345 | 3343 | ||
| 3346 | terminal->kboard = xmalloc (sizeof (KBOARD)); | 3344 | terminal->kboard = xmalloc (sizeof *terminal->kboard); |
| 3347 | init_kboard (terminal->kboard); | 3345 | init_kboard (terminal->kboard); |
| 3348 | KVAR (terminal->kboard, Vwindow_system) = Qnil; | 3346 | KVAR (terminal->kboard, Vwindow_system) = Qnil; |
| 3349 | terminal->kboard->next_kboard = all_kboards; | 3347 | terminal->kboard->next_kboard = all_kboards; |
diff --git a/src/termcap.c b/src/termcap.c index ea096d789da..d1b05e8df94 100644 --- a/src/termcap.c +++ b/src/termcap.c | |||
| @@ -478,7 +478,7 @@ tgetent (char *bp, const char *name) | |||
| 478 | { | 478 | { |
| 479 | ptrdiff_t offset1 = bp1 - bp, offset2 = tc_search_point - bp; | 479 | ptrdiff_t offset1 = bp1 - bp, offset2 = tc_search_point - bp; |
| 480 | malloc_size = offset1 + buf.size; | 480 | malloc_size = offset1 + buf.size; |
| 481 | bp = termcap_name = (char *) xrealloc (bp, malloc_size); | 481 | bp = termcap_name = xrealloc (bp, malloc_size); |
| 482 | bp1 = termcap_name + offset1; | 482 | bp1 = termcap_name + offset1; |
| 483 | tc_search_point = termcap_name + offset2; | 483 | tc_search_point = termcap_name + offset2; |
| 484 | } | 484 | } |
| @@ -504,7 +504,7 @@ tgetent (char *bp, const char *name) | |||
| 504 | xfree (buf.beg); | 504 | xfree (buf.beg); |
| 505 | 505 | ||
| 506 | if (malloc_size) | 506 | if (malloc_size) |
| 507 | bp = (char *) xrealloc (bp, bp1 - bp + 1); | 507 | bp = xrealloc (bp, bp1 - bp + 1); |
| 508 | 508 | ||
| 509 | ret: | 509 | ret: |
| 510 | term_entry = bp; | 510 | term_entry = bp; |
diff --git a/src/unexmacosx.c b/src/unexmacosx.c index 423853c8139..0f5ad5498b0 100644 --- a/src/unexmacosx.c +++ b/src/unexmacosx.c | |||
| @@ -394,7 +394,7 @@ build_region_list (void) | |||
| 394 | } | 394 | } |
| 395 | else | 395 | else |
| 396 | { | 396 | { |
| 397 | r = (struct region_t *) malloc (sizeof (struct region_t)); | 397 | r = malloc (sizeof *r); |
| 398 | 398 | ||
| 399 | if (!r) | 399 | if (!r) |
| 400 | unexec_error ("cannot allocate region structure"); | 400 | unexec_error ("cannot allocate region structure"); |
| @@ -669,7 +669,7 @@ read_load_commands (void) | |||
| 669 | #endif | 669 | #endif |
| 670 | 670 | ||
| 671 | nlc = mh.ncmds; | 671 | nlc = mh.ncmds; |
| 672 | lca = (struct load_command **) malloc (nlc * sizeof (struct load_command *)); | 672 | lca = malloc (nlc * sizeof *lca); |
| 673 | 673 | ||
| 674 | for (i = 0; i < nlc; i++) | 674 | for (i = 0; i < nlc; i++) |
| 675 | { | 675 | { |
| @@ -678,7 +678,7 @@ read_load_commands (void) | |||
| 678 | size first and then read the rest. */ | 678 | size first and then read the rest. */ |
| 679 | if (!unexec_read (&lc, sizeof (struct load_command))) | 679 | if (!unexec_read (&lc, sizeof (struct load_command))) |
| 680 | unexec_error ("cannot read load command"); | 680 | unexec_error ("cannot read load command"); |
| 681 | lca[i] = (struct load_command *) malloc (lc.cmdsize); | 681 | lca[i] = malloc (lc.cmdsize); |
| 682 | memcpy (lca[i], &lc, sizeof (struct load_command)); | 682 | memcpy (lca[i], &lc, sizeof (struct load_command)); |
| 683 | if (!unexec_read (lca[i] + 1, lc.cmdsize - sizeof (struct load_command))) | 683 | if (!unexec_read (lca[i] + 1, lc.cmdsize - sizeof (struct load_command))) |
| 684 | unexec_error ("cannot read content of load command"); | 684 | unexec_error ("cannot read content of load command"); |
| @@ -1378,7 +1378,7 @@ unexec_realloc (void *old_ptr, size_t new_size) | |||
| 1378 | size_t old_size = ((unexec_malloc_header_t *) old_ptr)[-1].u.size; | 1378 | size_t old_size = ((unexec_malloc_header_t *) old_ptr)[-1].u.size; |
| 1379 | size_t size = new_size > old_size ? old_size : new_size; | 1379 | size_t size = new_size > old_size ? old_size : new_size; |
| 1380 | 1380 | ||
| 1381 | p = (size_t *) malloc (new_size); | 1381 | p = malloc (new_size); |
| 1382 | if (size) | 1382 | if (size) |
| 1383 | memcpy (p, old_ptr, size); | 1383 | memcpy (p, old_ptr, size); |
| 1384 | } | 1384 | } |
diff --git a/src/window.c b/src/window.c index 229035fe81e..0f88cbaece9 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -5469,9 +5469,8 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5469 | really like to do is to free only those matrices not reused | 5469 | really like to do is to free only those matrices not reused |
| 5470 | below. */ | 5470 | below. */ |
| 5471 | root_window = XWINDOW (FRAME_ROOT_WINDOW (f)); | 5471 | root_window = XWINDOW (FRAME_ROOT_WINDOW (f)); |
| 5472 | leaf_windows | 5472 | leaf_windows = alloca (count_windows (root_window) |
| 5473 | = (struct window **) alloca (count_windows (root_window) | 5473 | * sizeof *leaf_windows); |
| 5474 | * sizeof (struct window *)); | ||
| 5475 | n_leaf_windows = get_leaf_windows (root_window, leaf_windows, 0); | 5474 | n_leaf_windows = get_leaf_windows (root_window, leaf_windows, 0); |
| 5476 | 5475 | ||
| 5477 | /* Kludge Alert! | 5476 | /* Kludge Alert! |
diff --git a/src/xdisp.c b/src/xdisp.c index 0c210198fc5..0684a68444e 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -5400,8 +5400,7 @@ load_overlay_strings (struct it *it, ptrdiff_t charpos) | |||
| 5400 | ptrdiff_t size = 20; | 5400 | ptrdiff_t size = 20; |
| 5401 | ptrdiff_t n = 0, i, j; | 5401 | ptrdiff_t n = 0, i, j; |
| 5402 | int invis_p; | 5402 | int invis_p; |
| 5403 | struct overlay_entry *entries | 5403 | struct overlay_entry *entries = alloca (size * sizeof *entries); |
| 5404 | = (struct overlay_entry *) alloca (size * sizeof *entries); | ||
| 5405 | USE_SAFE_ALLOCA; | 5404 | USE_SAFE_ALLOCA; |
| 5406 | 5405 | ||
| 5407 | if (charpos <= 0) | 5406 | if (charpos <= 0) |
| @@ -14949,7 +14948,7 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste | |||
| 14949 | return rc; | 14948 | return rc; |
| 14950 | #endif | 14949 | #endif |
| 14951 | 14950 | ||
| 14952 | /* Previously, there was a check for Lisp integer in the | 14951 | /* Previously, there was a check for Lisp integer in the |
| 14953 | if-statement below. Now, this field is converted to | 14952 | if-statement below. Now, this field is converted to |
| 14954 | ptrdiff_t, thus zero means invalid position in a buffer. */ | 14953 | ptrdiff_t, thus zero means invalid position in a buffer. */ |
| 14955 | eassert (w->last_point > 0); | 14954 | eassert (w->last_point > 0); |
| @@ -18012,7 +18011,7 @@ dump_glyph_row (struct glyph_row *row, int vpos, int glyphs) | |||
| 18012 | 18011 | ||
| 18013 | for (area = LEFT_MARGIN_AREA; area < LAST_AREA; ++area) | 18012 | for (area = LEFT_MARGIN_AREA; area < LAST_AREA; ++area) |
| 18014 | { | 18013 | { |
| 18015 | char *s = (char *) alloca (row->used[area] + 1); | 18014 | char *s = alloca (row->used[area] + 1); |
| 18016 | int i; | 18015 | int i; |
| 18017 | 18016 | ||
| 18018 | for (i = 0; i < row->used[area]; ++i) | 18017 | for (i = 0; i < row->used[area]; ++i) |
| @@ -21137,7 +21136,7 @@ decode_mode_spec_coding (Lisp_Object coding_system, register char *buf, int eol_ | |||
| 21137 | } | 21136 | } |
| 21138 | else if (CHARACTERP (eoltype)) | 21137 | else if (CHARACTERP (eoltype)) |
| 21139 | { | 21138 | { |
| 21140 | unsigned char *tmp = (unsigned char *) alloca (MAX_MULTIBYTE_LENGTH); | 21139 | unsigned char *tmp = alloca (MAX_MULTIBYTE_LENGTH); |
| 21141 | int c = XFASTINT (eoltype); | 21140 | int c = XFASTINT (eoltype); |
| 21142 | eol_str_len = CHAR_STRING (c, tmp); | 21141 | eol_str_len = CHAR_STRING (c, tmp); |
| 21143 | eol_str = tmp; | 21142 | eol_str = tmp; |
| @@ -23010,7 +23009,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, int backward_p) | |||
| 23010 | #define BUILD_STRETCH_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \ | 23009 | #define BUILD_STRETCH_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \ |
| 23011 | do \ | 23010 | do \ |
| 23012 | { \ | 23011 | { \ |
| 23013 | s = (struct glyph_string *) alloca (sizeof *s); \ | 23012 | s = alloca (sizeof *s); \ |
| 23014 | INIT_GLYPH_STRING (s, NULL, w, row, area, START, HL); \ | 23013 | INIT_GLYPH_STRING (s, NULL, w, row, area, START, HL); \ |
| 23015 | START = fill_stretch_glyph_string (s, START, END); \ | 23014 | START = fill_stretch_glyph_string (s, START, END); \ |
| 23016 | append_glyph_string (&HEAD, &TAIL, s); \ | 23015 | append_glyph_string (&HEAD, &TAIL, s); \ |
| @@ -23030,7 +23029,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, int backward_p) | |||
| 23030 | #define BUILD_IMAGE_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \ | 23029 | #define BUILD_IMAGE_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \ |
| 23031 | do \ | 23030 | do \ |
| 23032 | { \ | 23031 | { \ |
| 23033 | s = (struct glyph_string *) alloca (sizeof *s); \ | 23032 | s = alloca (sizeof *s); \ |
| 23034 | INIT_GLYPH_STRING (s, NULL, w, row, area, START, HL); \ | 23033 | INIT_GLYPH_STRING (s, NULL, w, row, area, START, HL); \ |
| 23035 | fill_image_glyph_string (s); \ | 23034 | fill_image_glyph_string (s); \ |
| 23036 | append_glyph_string (&HEAD, &TAIL, s); \ | 23035 | append_glyph_string (&HEAD, &TAIL, s); \ |
| @@ -23057,8 +23056,8 @@ compute_overhangs_and_x (struct glyph_string *s, int x, int backward_p) | |||
| 23057 | \ | 23056 | \ |
| 23058 | face_id = (row)->glyphs[area][START].face_id; \ | 23057 | face_id = (row)->glyphs[area][START].face_id; \ |
| 23059 | \ | 23058 | \ |
| 23060 | s = (struct glyph_string *) alloca (sizeof *s); \ | 23059 | s = alloca (sizeof *s); \ |
| 23061 | char2b = (XChar2b *) alloca ((END - START) * sizeof *char2b); \ | 23060 | char2b = alloca ((END - START) * sizeof *char2b); \ |
| 23062 | INIT_GLYPH_STRING (s, char2b, w, row, area, START, HL); \ | 23061 | INIT_GLYPH_STRING (s, char2b, w, row, area, START, HL); \ |
| 23063 | append_glyph_string (&HEAD, &TAIL, s); \ | 23062 | append_glyph_string (&HEAD, &TAIL, s); \ |
| 23064 | s->x = (X); \ | 23063 | s->x = (X); \ |
| @@ -23086,13 +23085,13 @@ compute_overhangs_and_x (struct glyph_string *s, int x, int backward_p) | |||
| 23086 | struct glyph_string *first_s = NULL; \ | 23085 | struct glyph_string *first_s = NULL; \ |
| 23087 | int n; \ | 23086 | int n; \ |
| 23088 | \ | 23087 | \ |
| 23089 | char2b = (XChar2b *) alloca ((sizeof *char2b) * cmp->glyph_len); \ | 23088 | char2b = alloca (cmp->glyph_len * sizeof *char2b); \ |
| 23090 | \ | 23089 | \ |
| 23091 | /* Make glyph_strings for each glyph sequence that is drawable by \ | 23090 | /* Make glyph_strings for each glyph sequence that is drawable by \ |
| 23092 | the same face, and append them to HEAD/TAIL. */ \ | 23091 | the same face, and append them to HEAD/TAIL. */ \ |
| 23093 | for (n = 0; n < cmp->glyph_len;) \ | 23092 | for (n = 0; n < cmp->glyph_len;) \ |
| 23094 | { \ | 23093 | { \ |
| 23095 | s = (struct glyph_string *) alloca (sizeof *s); \ | 23094 | s = alloca (sizeof *s); \ |
| 23096 | INIT_GLYPH_STRING (s, char2b, w, row, area, START, HL); \ | 23095 | INIT_GLYPH_STRING (s, char2b, w, row, area, START, HL); \ |
| 23097 | append_glyph_string (&(HEAD), &(TAIL), s); \ | 23096 | append_glyph_string (&(HEAD), &(TAIL), s); \ |
| 23098 | s->cmp = cmp; \ | 23097 | s->cmp = cmp; \ |
| @@ -23120,9 +23119,8 @@ compute_overhangs_and_x (struct glyph_string *s, int x, int backward_p) | |||
| 23120 | face_id = (row)->glyphs[area][START].face_id; \ | 23119 | face_id = (row)->glyphs[area][START].face_id; \ |
| 23121 | gstring = (composition_gstring_from_id \ | 23120 | gstring = (composition_gstring_from_id \ |
| 23122 | ((row)->glyphs[area][START].u.cmp.id)); \ | 23121 | ((row)->glyphs[area][START].u.cmp.id)); \ |
| 23123 | s = (struct glyph_string *) alloca (sizeof *s); \ | 23122 | s = alloca (sizeof *s); \ |
| 23124 | char2b = (XChar2b *) alloca ((sizeof *char2b) \ | 23123 | char2b = alloca (LGSTRING_GLYPH_LEN (gstring) * sizeof *char2b); \ |
| 23125 | * LGSTRING_GLYPH_LEN (gstring)); \ | ||
| 23126 | INIT_GLYPH_STRING (s, char2b, w, row, area, START, HL); \ | 23124 | INIT_GLYPH_STRING (s, char2b, w, row, area, START, HL); \ |
| 23127 | append_glyph_string (&(HEAD), &(TAIL), s); \ | 23125 | append_glyph_string (&(HEAD), &(TAIL), s); \ |
| 23128 | s->x = (X); \ | 23126 | s->x = (X); \ |
| @@ -23141,7 +23139,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, int backward_p) | |||
| 23141 | \ | 23139 | \ |
| 23142 | face_id = (row)->glyphs[area][START].face_id; \ | 23140 | face_id = (row)->glyphs[area][START].face_id; \ |
| 23143 | \ | 23141 | \ |
| 23144 | s = (struct glyph_string *) alloca (sizeof *s); \ | 23142 | s = alloca (sizeof *s); \ |
| 23145 | INIT_GLYPH_STRING (s, NULL, w, row, area, START, HL); \ | 23143 | INIT_GLYPH_STRING (s, NULL, w, row, area, START, HL); \ |
| 23146 | append_glyph_string (&HEAD, &TAIL, s); \ | 23144 | append_glyph_string (&HEAD, &TAIL, s); \ |
| 23147 | s->x = (X); \ | 23145 | s->x = (X); \ |
diff --git a/src/xfaces.c b/src/xfaces.c index 28ef5e6cd13..a1062a44232 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -703,9 +703,8 @@ x_create_gc (struct frame *f, | |||
| 703 | unsigned long mask, | 703 | unsigned long mask, |
| 704 | XGCValues *xgcv) | 704 | XGCValues *xgcv) |
| 705 | { | 705 | { |
| 706 | GC gc = xmalloc (sizeof (*gc)); | 706 | GC gc = xmalloc (sizeof *gc); |
| 707 | if (gc) | 707 | memcpy (gc, xgcv, sizeof (XGCValues)); |
| 708 | memcpy (gc, xgcv, sizeof (XGCValues)); | ||
| 709 | return gc; | 708 | return gc; |
| 710 | } | 709 | } |
| 711 | 710 | ||
| @@ -2951,7 +2950,7 @@ FRAME 0 means change the face on all frames, and change the default | |||
| 2951 | else if (EQ (attr, QCunderline)) | 2950 | else if (EQ (attr, QCunderline)) |
| 2952 | { | 2951 | { |
| 2953 | int valid_p = 0; | 2952 | int valid_p = 0; |
| 2954 | 2953 | ||
| 2955 | if (UNSPECIFIEDP (value) || IGNORE_DEFFACE_P (value)) | 2954 | if (UNSPECIFIEDP (value) || IGNORE_DEFFACE_P (value)) |
| 2956 | valid_p = 1; | 2955 | valid_p = 1; |
| 2957 | else if (NILP (value) || EQ (value, Qt)) | 2956 | else if (NILP (value) || EQ (value, Qt)) |
| @@ -2971,8 +2970,8 @@ FRAME 0 means change the face on all frames, and change the default | |||
| 2971 | list = CDR_SAFE (list); | 2970 | list = CDR_SAFE (list); |
| 2972 | val = CAR_SAFE (list); | 2971 | val = CAR_SAFE (list); |
| 2973 | list = CDR_SAFE (list); | 2972 | list = CDR_SAFE (list); |
| 2974 | 2973 | ||
| 2975 | if(NILP (key) || NILP (val)) | 2974 | if (NILP (key) || NILP (val)) |
| 2976 | { | 2975 | { |
| 2977 | valid_p = 0; | 2976 | valid_p = 0; |
| 2978 | break; | 2977 | break; |
| @@ -2985,8 +2984,8 @@ FRAME 0 means change the face on all frames, and change the default | |||
| 2985 | valid_p = 0; | 2984 | valid_p = 0; |
| 2986 | break; | 2985 | break; |
| 2987 | } | 2986 | } |
| 2988 | 2987 | ||
| 2989 | else if (EQ (key, QCstyle) | 2988 | else if (EQ (key, QCstyle) |
| 2990 | && !(EQ (val, Qline) || EQ (val, Qwave))) | 2989 | && !(EQ (val, Qline) || EQ (val, Qwave))) |
| 2991 | { | 2990 | { |
| 2992 | valid_p = 0; | 2991 | valid_p = 0; |
| @@ -2994,10 +2993,10 @@ FRAME 0 means change the face on all frames, and change the default | |||
| 2994 | } | 2993 | } |
| 2995 | } | 2994 | } |
| 2996 | } | 2995 | } |
| 2997 | 2996 | ||
| 2998 | if (!valid_p) | 2997 | if (!valid_p) |
| 2999 | signal_error ("Invalid face underline", value); | 2998 | signal_error ("Invalid face underline", value); |
| 3000 | 2999 | ||
| 3001 | old_value = LFACE_UNDERLINE (lface); | 3000 | old_value = LFACE_UNDERLINE (lface); |
| 3002 | LFACE_UNDERLINE (lface) = value; | 3001 | LFACE_UNDERLINE (lface) = value; |
| 3003 | } | 3002 | } |
| @@ -5774,7 +5773,7 @@ realize_x_face (struct face_cache *cache, Lisp_Object *attrs) | |||
| 5774 | } | 5773 | } |
| 5775 | else if (CONSP (underline)) | 5774 | else if (CONSP (underline)) |
| 5776 | { | 5775 | { |
| 5777 | /* `(:color COLOR :style STYLE)'. | 5776 | /* `(:color COLOR :style STYLE)'. |
| 5778 | STYLE being one of `line' or `wave'. */ | 5777 | STYLE being one of `line' or `wave'. */ |
| 5779 | face->underline_p = 1; | 5778 | face->underline_p = 1; |
| 5780 | face->underline_color = 0; | 5779 | face->underline_color = 0; |
| @@ -5816,7 +5815,7 @@ realize_x_face (struct face_cache *cache, Lisp_Object *attrs) | |||
| 5816 | } | 5815 | } |
| 5817 | } | 5816 | } |
| 5818 | } | 5817 | } |
| 5819 | 5818 | ||
| 5820 | overline = attrs[LFACE_OVERLINE_INDEX]; | 5819 | overline = attrs[LFACE_OVERLINE_INDEX]; |
| 5821 | if (STRINGP (overline)) | 5820 | if (STRINGP (overline)) |
| 5822 | { | 5821 | { |
diff --git a/src/xfns.c b/src/xfns.c index e90f3099f21..ec729fab566 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -1881,7 +1881,7 @@ xic_create_fontsetname (const char *base_fontname, int motif) | |||
| 1881 | 1881 | ||
| 1882 | /* Make a fontset name from the base font name. */ | 1882 | /* Make a fontset name from the base font name. */ |
| 1883 | if (xic_default_fontset == base_fontname) | 1883 | if (xic_default_fontset == base_fontname) |
| 1884 | { | 1884 | { |
| 1885 | /* There is no base font name, use the default. */ | 1885 | /* There is no base font name, use the default. */ |
| 1886 | fontsetname = xmalloc (strlen (base_fontname) + 2); | 1886 | fontsetname = xmalloc (strlen (base_fontname) + 2); |
| 1887 | strcpy (fontsetname, base_fontname); | 1887 | strcpy (fontsetname, base_fontname); |
| @@ -1953,21 +1953,21 @@ xic_create_fontsetname (const char *base_fontname, int motif) | |||
| 1953 | 1953 | ||
| 1954 | /* Build the font spec that matches all charsets. */ | 1954 | /* Build the font spec that matches all charsets. */ |
| 1955 | len = p - base_fontname + strlen (allcs) + 1; | 1955 | len = p - base_fontname + strlen (allcs) + 1; |
| 1956 | font_allcs = (char *) alloca (len); | 1956 | font_allcs = alloca (len); |
| 1957 | memcpy (font_allcs, base_fontname, p - base_fontname); | 1957 | memcpy (font_allcs, base_fontname, p - base_fontname); |
| 1958 | strcat (font_allcs, allcs); | 1958 | strcat (font_allcs, allcs); |
| 1959 | 1959 | ||
| 1960 | /* Build the font spec that matches all families and | 1960 | /* Build the font spec that matches all families and |
| 1961 | add-styles. */ | 1961 | add-styles. */ |
| 1962 | len = p - p1 + strlen (allcs) + strlen (allfamilies) + 1; | 1962 | len = p - p1 + strlen (allcs) + strlen (allfamilies) + 1; |
| 1963 | font_allfamilies = (char *) alloca (len); | 1963 | font_allfamilies = alloca (len); |
| 1964 | strcpy (font_allfamilies, allfamilies); | 1964 | strcpy (font_allfamilies, allfamilies); |
| 1965 | memcpy (font_allfamilies + strlen (allfamilies), p1, p - p1); | 1965 | memcpy (font_allfamilies + strlen (allfamilies), p1, p - p1); |
| 1966 | strcat (font_allfamilies, allcs); | 1966 | strcat (font_allfamilies, allcs); |
| 1967 | 1967 | ||
| 1968 | /* Build the font spec that matches all. */ | 1968 | /* Build the font spec that matches all. */ |
| 1969 | len = p - p2 + strlen (allcs) + strlen (all) + strlen (allfamilies) + 1; | 1969 | len = p - p2 + strlen (allcs) + strlen (all) + strlen (allfamilies) + 1; |
| 1970 | font_all = (char *) alloca (len); | 1970 | font_all = alloca (len); |
| 1971 | strcpy (font_all, allfamilies); | 1971 | strcpy (font_all, allfamilies); |
| 1972 | strcat (font_all, all); | 1972 | strcat (font_all, all); |
| 1973 | memcpy (font_all + strlen (all) + strlen (allfamilies), p2, p - p2); | 1973 | memcpy (font_all + strlen (all) + strlen (allfamilies), p2, p - p2); |
| @@ -3129,7 +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 = xzalloc (sizeof (struct x_output)); | 3132 | f->output_data.x = xzalloc (sizeof *f->output_data.x); |
| 3133 | f->output_data.x->icon_bitmap = -1; | 3133 | f->output_data.x->icon_bitmap = -1; |
| 3134 | FRAME_FONTSET (f) = -1; | 3134 | FRAME_FONTSET (f) = -1; |
| 3135 | f->output_data.x->scroll_bar_foreground_pixel = -1; | 3135 | f->output_data.x->scroll_bar_foreground_pixel = -1; |
| @@ -3957,7 +3957,7 @@ select_visual (struct x_display_info *dpyinfo) | |||
| 3957 | /* VALUE should be of the form CLASS-DEPTH, where CLASS is one | 3957 | /* VALUE should be of the form CLASS-DEPTH, where CLASS is one |
| 3958 | of `PseudoColor', `TrueColor' etc. and DEPTH is the color | 3958 | of `PseudoColor', `TrueColor' etc. and DEPTH is the color |
| 3959 | depth, a decimal number. NAME is compared with case ignored. */ | 3959 | depth, a decimal number. NAME is compared with case ignored. */ |
| 3960 | char *s = (char *) alloca (SBYTES (value) + 1); | 3960 | char *s = alloca (SBYTES (value) + 1); |
| 3961 | char *dash; | 3961 | char *dash; |
| 3962 | int i, class = -1; | 3962 | int i, class = -1; |
| 3963 | XVisualInfo vinfo; | 3963 | XVisualInfo vinfo; |
| @@ -4614,7 +4614,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo, | |||
| 4614 | from this point on, x_destroy_window might screw up reference | 4614 | from this point on, x_destroy_window might screw up reference |
| 4615 | counts etc. */ | 4615 | counts etc. */ |
| 4616 | f->output_method = output_x_window; | 4616 | f->output_method = output_x_window; |
| 4617 | f->output_data.x = xzalloc (sizeof (struct x_output)); | 4617 | f->output_data.x = xzalloc (sizeof *f->output_data.x); |
| 4618 | f->output_data.x->icon_bitmap = -1; | 4618 | f->output_data.x->icon_bitmap = -1; |
| 4619 | FRAME_FONTSET (f) = -1; | 4619 | FRAME_FONTSET (f) = -1; |
| 4620 | f->output_data.x->scroll_bar_foreground_pixel = -1; | 4620 | f->output_data.x->scroll_bar_foreground_pixel = -1; |
diff --git a/src/xftfont.c b/src/xftfont.c index bc0c56a0fe0..f999ac662ce 100644 --- a/src/xftfont.c +++ b/src/xftfont.c | |||
| @@ -527,7 +527,7 @@ xftfont_prepare_face (FRAME_PTR f, struct face *face) | |||
| 527 | } | 527 | } |
| 528 | #endif | 528 | #endif |
| 529 | 529 | ||
| 530 | xftface_info = malloc (sizeof (struct xftface_info)); | 530 | xftface_info = malloc (sizeof *xftface_info); |
| 531 | if (! xftface_info) | 531 | if (! xftface_info) |
| 532 | return -1; | 532 | return -1; |
| 533 | xftfont_get_colors (f, face, face->gc, NULL, | 533 | xftfont_get_colors (f, face, face->gc, NULL, |
diff --git a/src/xgselect.c b/src/xgselect.c index c7348d2c70a..3752056bd76 100644 --- a/src/xgselect.c +++ b/src/xgselect.c | |||
| @@ -153,6 +153,6 @@ xgselect_initialize (void) | |||
| 153 | { | 153 | { |
| 154 | #if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS) | 154 | #if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS) |
| 155 | gfds_size = 128; | 155 | gfds_size = 128; |
| 156 | gfds = xmalloc (sizeof (*gfds)*gfds_size); | 156 | gfds = xmalloc (gfds_size * sizeof *gfds); |
| 157 | #endif | 157 | #endif |
| 158 | } | 158 | } |
diff --git a/src/xmenu.c b/src/xmenu.c index b7dd547737d..5a6390449c4 100644 --- a/src/xmenu.c +++ b/src/xmenu.c | |||
| @@ -980,8 +980,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) | |||
| 980 | ptrdiff_t specpdl_count = SPECPDL_INDEX (); | 980 | ptrdiff_t specpdl_count = SPECPDL_INDEX (); |
| 981 | int previous_menu_items_used = f->menu_bar_items_used; | 981 | int previous_menu_items_used = f->menu_bar_items_used; |
| 982 | Lisp_Object *previous_items | 982 | Lisp_Object *previous_items |
| 983 | = (Lisp_Object *) alloca (previous_menu_items_used | 983 | = alloca (previous_menu_items_used * sizeof *previous_items); |
| 984 | * sizeof (Lisp_Object)); | ||
| 985 | int subitems; | 984 | int subitems; |
| 986 | 985 | ||
| 987 | /* If we are making a new widget, its contents are empty, | 986 | /* If we are making a new widget, its contents are empty, |
| @@ -1028,10 +1027,11 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) | |||
| 1028 | menu_items = f->menu_bar_vector; | 1027 | menu_items = f->menu_bar_vector; |
| 1029 | menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0; | 1028 | menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0; |
| 1030 | subitems = ASIZE (items) / 4; | 1029 | subitems = ASIZE (items) / 4; |
| 1031 | submenu_start = (int *) alloca ((subitems + 1) * sizeof (int)); | 1030 | submenu_start = alloca ((subitems + 1) * sizeof *submenu_start); |
| 1032 | submenu_end = (int *) alloca (subitems * sizeof (int)); | 1031 | submenu_end = alloca (subitems * sizeof *submenu_end); |
| 1033 | submenu_n_panes = (int *) alloca (subitems * sizeof (int)); | 1032 | submenu_n_panes = alloca (subitems * sizeof *submenu_n_panes); |
| 1034 | submenu_top_level_items = (int *) alloca (subitems * sizeof (int)); | 1033 | submenu_top_level_items = alloca (subitems |
| 1034 | * sizeof *submenu_top_level_items); | ||
| 1035 | init_menu_items (); | 1035 | init_menu_items (); |
| 1036 | for (i = 0; i < subitems; i++) | 1036 | for (i = 0; i < subitems; i++) |
| 1037 | { | 1037 | { |
| @@ -1639,9 +1639,9 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, | |||
| 1639 | int i; | 1639 | int i; |
| 1640 | widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0; | 1640 | widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0; |
| 1641 | widget_value **submenu_stack | 1641 | widget_value **submenu_stack |
| 1642 | = (widget_value **) alloca (menu_items_used * sizeof (widget_value *)); | 1642 | = alloca (menu_items_used * sizeof *submenu_stack); |
| 1643 | Lisp_Object *subprefix_stack | 1643 | Lisp_Object *subprefix_stack |
| 1644 | = (Lisp_Object *) alloca (menu_items_used * sizeof (Lisp_Object)); | 1644 | = alloca (menu_items_used * sizeof *subprefix_stack); |
| 1645 | int submenu_depth = 0; | 1645 | int submenu_depth = 0; |
| 1646 | 1646 | ||
| 1647 | int first_pane; | 1647 | int first_pane; |
| @@ -2416,7 +2416,7 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, | |||
| 2416 | { | 2416 | { |
| 2417 | /* if alloca is fast, use that to make the space, | 2417 | /* if alloca is fast, use that to make the space, |
| 2418 | to reduce gc needs. */ | 2418 | to reduce gc needs. */ |
| 2419 | item_data = (char *) alloca (maxwidth + SBYTES (descrip) + 1); | 2419 | item_data = alloca (maxwidth + SBYTES (descrip) + 1); |
| 2420 | memcpy (item_data, SSDATA (item_name), SBYTES (item_name)); | 2420 | memcpy (item_data, SSDATA (item_name), SBYTES (item_name)); |
| 2421 | for (j = SCHARS (item_name); j < maxwidth; j++) | 2421 | for (j = SCHARS (item_name); j < maxwidth; j++) |
| 2422 | item_data[j] = ' '; | 2422 | item_data[j] = ' '; |
diff --git a/src/xrdb.c b/src/xrdb.c index 1e68205b630..624bafa5e92 100644 --- a/src/xrdb.c +++ b/src/xrdb.c | |||
| @@ -74,10 +74,8 @@ static char * | |||
| 74 | x_get_customization_string (XrmDatabase db, const char *name, | 74 | x_get_customization_string (XrmDatabase db, const char *name, |
| 75 | const char *class) | 75 | const char *class) |
| 76 | { | 76 | { |
| 77 | char *full_name | 77 | char *full_name = alloca (strlen (name) + sizeof "customization" + 3); |
| 78 | = (char *) alloca (strlen (name) + sizeof ("customization") + 3); | 78 | char *full_class = alloca (strlen (class) + sizeof "Customization" + 3); |
| 79 | char *full_class | ||
| 80 | = (char *) alloca (strlen (class) + sizeof ("Customization") + 3); | ||
| 81 | char *result; | 79 | char *result; |
| 82 | 80 | ||
| 83 | sprintf (full_name, "%s.%s", name, "customization"); | 81 | sprintf (full_name, "%s.%s", name, "customization"); |
| @@ -206,7 +204,7 @@ magic_file_p (const char *string, ptrdiff_t string_len, const char *class, | |||
| 206 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 - 1 - path_len < next_len) | 204 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 - 1 - path_len < next_len) |
| 207 | memory_full (SIZE_MAX); | 205 | memory_full (SIZE_MAX); |
| 208 | path_size = (path_len + next_len + 1) * 2; | 206 | path_size = (path_len + next_len + 1) * 2; |
| 209 | path = (char *) xrealloc (path, path_size); | 207 | path = xrealloc (path, path_size); |
| 210 | } | 208 | } |
| 211 | 209 | ||
| 212 | memcpy (path + path_len, next, next_len); | 210 | memcpy (path + path_len, next, next_len); |
| @@ -400,7 +398,7 @@ get_user_db (Display *display) | |||
| 400 | char *xdefault; | 398 | char *xdefault; |
| 401 | 399 | ||
| 402 | home = gethomedir (); | 400 | home = gethomedir (); |
| 403 | xdefault = xmalloc (strlen (home) + sizeof (".Xdefaults")); | 401 | xdefault = xmalloc (strlen (home) + sizeof ".Xdefaults"); |
| 404 | strcpy (xdefault, home); | 402 | strcpy (xdefault, home); |
| 405 | strcat (xdefault, ".Xdefaults"); | 403 | strcat (xdefault, ".Xdefaults"); |
| 406 | db = XrmGetFileDatabase (xdefault); | 404 | db = XrmGetFileDatabase (xdefault); |
| @@ -434,7 +432,7 @@ get_environ_db (void) | |||
| 434 | char *home = gethomedir (); | 432 | char *home = gethomedir (); |
| 435 | char const *host = get_system_name (); | 433 | char const *host = get_system_name (); |
| 436 | ptrdiff_t pathsize = strlen (home) + sizeof xdefaults + strlen (host); | 434 | ptrdiff_t pathsize = strlen (home) + sizeof xdefaults + strlen (host); |
| 437 | path = (char *) xrealloc (home, pathsize); | 435 | path = xrealloc (home, pathsize); |
| 438 | strcat (strcat (path, xdefaults), host); | 436 | strcat (strcat (path, xdefaults), host); |
| 439 | p = path; | 437 | p = path; |
| 440 | } | 438 | } |
diff --git a/src/xselect.c b/src/xselect.c index 67785b26353..e2da561e953 100644 --- a/src/xselect.c +++ b/src/xselect.c | |||
| @@ -180,7 +180,7 @@ x_queue_event (struct input_event *event) | |||
| 180 | } | 180 | } |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | queue_tmp = xmalloc (sizeof (struct selection_event_queue)); | 183 | queue_tmp = xmalloc (sizeof *queue_tmp); |
| 184 | TRACE1 ("QUEUE SELECTION EVENT %p", queue_tmp); | 184 | TRACE1 ("QUEUE SELECTION EVENT %p", queue_tmp); |
| 185 | queue_tmp->event = *event; | 185 | queue_tmp->event = *event; |
| 186 | queue_tmp->next = selection_queue; | 186 | queue_tmp->next = selection_queue; |
| @@ -907,7 +907,7 @@ x_convert_selection (struct input_event *event, Lisp_Object selection_symbol, | |||
| 907 | { | 907 | { |
| 908 | if (for_multiple) | 908 | if (for_multiple) |
| 909 | { | 909 | { |
| 910 | cs = xmalloc (sizeof (struct selection_data)); | 910 | cs = xmalloc (sizeof *cs); |
| 911 | cs->data = (unsigned char *) &conversion_fail_tag; | 911 | cs->data = (unsigned char *) &conversion_fail_tag; |
| 912 | cs->size = 1; | 912 | cs->size = 1; |
| 913 | cs->format = 32; | 913 | cs->format = 32; |
| @@ -924,7 +924,7 @@ x_convert_selection (struct input_event *event, Lisp_Object selection_symbol, | |||
| 924 | } | 924 | } |
| 925 | 925 | ||
| 926 | /* Otherwise, record the converted selection to binary. */ | 926 | /* Otherwise, record the converted selection to binary. */ |
| 927 | cs = xmalloc (sizeof (struct selection_data)); | 927 | cs = xmalloc (sizeof *cs); |
| 928 | cs->data = NULL; | 928 | cs->data = NULL; |
| 929 | cs->nofree = 1; | 929 | cs->nofree = 1; |
| 930 | cs->property = property; | 930 | cs->property = property; |
| @@ -1775,20 +1775,24 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj, | |||
| 1775 | } | 1775 | } |
| 1776 | else if (SYMBOLP (obj)) | 1776 | else if (SYMBOLP (obj)) |
| 1777 | { | 1777 | { |
| 1778 | *data_ret = xmalloc (sizeof (Atom) + 1); | 1778 | void *data = xmalloc (sizeof (Atom) + 1); |
| 1779 | Atom *x_atom_ptr = data; | ||
| 1780 | *data_ret = data; | ||
| 1779 | *format_ret = 32; | 1781 | *format_ret = 32; |
| 1780 | *size_ret = 1; | 1782 | *size_ret = 1; |
| 1781 | (*data_ret) [sizeof (Atom)] = 0; | 1783 | (*data_ret) [sizeof (Atom)] = 0; |
| 1782 | (*(Atom **) data_ret) [0] = symbol_to_x_atom (dpyinfo, obj); | 1784 | *x_atom_ptr = symbol_to_x_atom (dpyinfo, obj); |
| 1783 | if (NILP (type)) type = QATOM; | 1785 | if (NILP (type)) type = QATOM; |
| 1784 | } | 1786 | } |
| 1785 | else if (RANGED_INTEGERP (X_SHRT_MIN, obj, X_SHRT_MAX)) | 1787 | else if (RANGED_INTEGERP (X_SHRT_MIN, obj, X_SHRT_MAX)) |
| 1786 | { | 1788 | { |
| 1787 | *data_ret = xmalloc (sizeof (short) + 1); | 1789 | void *data = xmalloc (sizeof (short) + 1); |
| 1790 | short *short_ptr = data; | ||
| 1791 | *data_ret = data; | ||
| 1788 | *format_ret = 16; | 1792 | *format_ret = 16; |
| 1789 | *size_ret = 1; | 1793 | *size_ret = 1; |
| 1790 | (*data_ret) [sizeof (short)] = 0; | 1794 | (*data_ret) [sizeof (short)] = 0; |
| 1791 | (*(short **) data_ret) [0] = XINT (obj); | 1795 | *short_ptr = XINT (obj); |
| 1792 | if (NILP (type)) type = QINTEGER; | 1796 | if (NILP (type)) type = QINTEGER; |
| 1793 | } | 1797 | } |
| 1794 | else if (INTEGERP (obj) | 1798 | else if (INTEGERP (obj) |
| @@ -1797,11 +1801,13 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj, | |||
| 1797 | || (CONSP (XCDR (obj)) | 1801 | || (CONSP (XCDR (obj)) |
| 1798 | && INTEGERP (XCAR (XCDR (obj))))))) | 1802 | && INTEGERP (XCAR (XCDR (obj))))))) |
| 1799 | { | 1803 | { |
| 1800 | *data_ret = xmalloc (sizeof (unsigned long) + 1); | 1804 | void *data = xmalloc (sizeof (unsigned long) + 1); |
| 1805 | unsigned long *x_long_ptr = data; | ||
| 1806 | *data_ret = data; | ||
| 1801 | *format_ret = 32; | 1807 | *format_ret = 32; |
| 1802 | *size_ret = 1; | 1808 | *size_ret = 1; |
| 1803 | (*data_ret) [sizeof (unsigned long)] = 0; | 1809 | (*data_ret) [sizeof (unsigned long)] = 0; |
| 1804 | (*(unsigned long **) data_ret) [0] = cons_to_x_long (obj); | 1810 | *x_long_ptr = cons_to_x_long (obj); |
| 1805 | if (NILP (type)) type = QINTEGER; | 1811 | if (NILP (type)) type = QINTEGER; |
| 1806 | } | 1812 | } |
| 1807 | else if (VECTORP (obj)) | 1813 | else if (VECTORP (obj)) |
| @@ -1816,23 +1822,28 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj, | |||
| 1816 | if (SYMBOLP (AREF (obj, 0))) | 1822 | if (SYMBOLP (AREF (obj, 0))) |
| 1817 | /* This vector is an ATOM set */ | 1823 | /* This vector is an ATOM set */ |
| 1818 | { | 1824 | { |
| 1825 | void *data; | ||
| 1826 | Atom *x_atoms; | ||
| 1819 | if (NILP (type)) type = QATOM; | 1827 | if (NILP (type)) type = QATOM; |
| 1820 | for (i = 0; i < size; i++) | 1828 | for (i = 0; i < size; i++) |
| 1821 | if (!SYMBOLP (AREF (obj, i))) | 1829 | if (!SYMBOLP (AREF (obj, i))) |
| 1822 | signal_error ("All elements of selection vector must have same type", obj); | 1830 | signal_error ("All elements of selection vector must have same type", obj); |
| 1823 | 1831 | ||
| 1824 | *data_ret = xnmalloc (size, sizeof (Atom)); | 1832 | *data_ret = data = xnmalloc (size, sizeof *x_atoms); |
| 1833 | x_atoms = data; | ||
| 1825 | *format_ret = 32; | 1834 | *format_ret = 32; |
| 1826 | *size_ret = size; | 1835 | *size_ret = size; |
| 1827 | for (i = 0; i < size; i++) | 1836 | for (i = 0; i < size; i++) |
| 1828 | (*(Atom **) data_ret) [i] | 1837 | x_atoms[i] = symbol_to_x_atom (dpyinfo, AREF (obj, i)); |
| 1829 | = symbol_to_x_atom (dpyinfo, AREF (obj, i)); | ||
| 1830 | } | 1838 | } |
| 1831 | else | 1839 | else |
| 1832 | /* This vector is an INTEGER set, or something like it */ | 1840 | /* This vector is an INTEGER set, or something like it */ |
| 1833 | { | 1841 | { |
| 1834 | int format = 16; | 1842 | int format = 16; |
| 1835 | int data_size = sizeof (short); | 1843 | int data_size = sizeof (short); |
| 1844 | void *data; | ||
| 1845 | unsigned long *x_atoms; | ||
| 1846 | short *shorts; | ||
| 1836 | if (NILP (type)) type = QINTEGER; | 1847 | if (NILP (type)) type = QINTEGER; |
| 1837 | for (i = 0; i < size; i++) | 1848 | for (i = 0; i < size; i++) |
| 1838 | { | 1849 | { |
| @@ -1847,17 +1858,17 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj, | |||
| 1847 | break; | 1858 | break; |
| 1848 | } | 1859 | } |
| 1849 | } | 1860 | } |
| 1850 | *data_ret = xnmalloc (size, data_size); | 1861 | *data_ret = data = xnmalloc (size, data_size); |
| 1862 | x_atoms = data; | ||
| 1863 | shorts = data; | ||
| 1851 | *format_ret = format; | 1864 | *format_ret = format; |
| 1852 | *size_ret = size; | 1865 | *size_ret = size; |
| 1853 | for (i = 0; i < size; i++) | 1866 | for (i = 0; i < size; i++) |
| 1854 | { | 1867 | { |
| 1855 | if (format == 32) | 1868 | if (format == 32) |
| 1856 | (*((unsigned long **) data_ret)) [i] = | 1869 | x_atoms[i] = cons_to_x_long (AREF (obj, i)); |
| 1857 | cons_to_x_long (AREF (obj, i)); | ||
| 1858 | else | 1870 | else |
| 1859 | (*((short **) data_ret)) [i] = | 1871 | shorts[i] = XINT (AREF (obj, i)); |
| 1860 | XINT (AREF (obj, i)); | ||
| 1861 | } | 1872 | } |
| 1862 | } | 1873 | } |
| 1863 | } | 1874 | } |
diff --git a/src/xterm.c b/src/xterm.c index 1562ab08056..b73290ccd00 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -6450,7 +6450,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, | |||
| 6450 | if (status_return == XBufferOverflow) | 6450 | if (status_return == XBufferOverflow) |
| 6451 | { | 6451 | { |
| 6452 | copy_bufsiz = nbytes + 1; | 6452 | copy_bufsiz = nbytes + 1; |
| 6453 | copy_bufptr = (unsigned char *) alloca (copy_bufsiz); | 6453 | copy_bufptr = alloca (copy_bufsiz); |
| 6454 | nbytes = XmbLookupString (FRAME_XIC (f), | 6454 | nbytes = XmbLookupString (FRAME_XIC (f), |
| 6455 | &event.xkey, (char *) copy_bufptr, | 6455 | &event.xkey, (char *) copy_bufptr, |
| 6456 | copy_bufsiz, &keysym, | 6456 | copy_bufsiz, &keysym, |
| @@ -7670,7 +7670,7 @@ x_error_catcher (Display *display, XErrorEvent *event) | |||
| 7670 | void | 7670 | void |
| 7671 | x_catch_errors (Display *dpy) | 7671 | x_catch_errors (Display *dpy) |
| 7672 | { | 7672 | { |
| 7673 | struct x_error_message_stack *data = xmalloc (sizeof (*data)); | 7673 | struct x_error_message_stack *data = xmalloc (sizeof *data); |
| 7674 | 7674 | ||
| 7675 | /* Make sure any errors from previous requests have been dealt with. */ | 7675 | /* Make sure any errors from previous requests have been dealt with. */ |
| 7676 | XSync (dpy, False); | 7676 | XSync (dpy, False); |
| @@ -7798,7 +7798,7 @@ x_connection_closed (Display *dpy, const char *error_message) | |||
| 7798 | Lisp_Object frame, tail; | 7798 | Lisp_Object frame, tail; |
| 7799 | ptrdiff_t idx = SPECPDL_INDEX (); | 7799 | ptrdiff_t idx = SPECPDL_INDEX (); |
| 7800 | 7800 | ||
| 7801 | error_msg = (char *) alloca (strlen (error_message) + 1); | 7801 | error_msg = alloca (strlen (error_message) + 1); |
| 7802 | strcpy (error_msg, error_message); | 7802 | strcpy (error_msg, error_message); |
| 7803 | handling_signal = 0; | 7803 | handling_signal = 0; |
| 7804 | 7804 | ||
| @@ -8187,10 +8187,9 @@ xim_initialize (struct x_display_info *dpyinfo, char *resource_name) | |||
| 8187 | if (use_xim) | 8187 | if (use_xim) |
| 8188 | { | 8188 | { |
| 8189 | #ifdef HAVE_X11R6_XIM | 8189 | #ifdef HAVE_X11R6_XIM |
| 8190 | struct xim_inst_t *xim_inst; | 8190 | struct xim_inst_t *xim_inst = xmalloc (sizeof *xim_inst); |
| 8191 | ptrdiff_t len; | 8191 | ptrdiff_t len; |
| 8192 | 8192 | ||
| 8193 | xim_inst = xmalloc (sizeof (struct xim_inst_t)); | ||
| 8194 | dpyinfo->xim_callback_data = xim_inst; | 8193 | dpyinfo->xim_callback_data = xim_inst; |
| 8195 | xim_inst->dpyinfo = dpyinfo; | 8194 | xim_inst->dpyinfo = dpyinfo; |
| 8196 | len = strlen (resource_name); | 8195 | len = strlen (resource_name); |
| @@ -10098,7 +10097,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 10098 | 10097 | ||
| 10099 | /* We have definitely succeeded. Record the new connection. */ | 10098 | /* We have definitely succeeded. Record the new connection. */ |
| 10100 | 10099 | ||
| 10101 | dpyinfo = xzalloc (sizeof (struct x_display_info)); | 10100 | dpyinfo = xzalloc (sizeof *dpyinfo); |
| 10102 | hlinfo = &dpyinfo->mouse_highlight; | 10101 | hlinfo = &dpyinfo->mouse_highlight; |
| 10103 | 10102 | ||
| 10104 | terminal = x_create_terminal (dpyinfo); | 10103 | terminal = x_create_terminal (dpyinfo); |
| @@ -10116,7 +10115,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 10116 | terminal->kboard = share->terminal->kboard; | 10115 | terminal->kboard = share->terminal->kboard; |
| 10117 | else | 10116 | else |
| 10118 | { | 10117 | { |
| 10119 | terminal->kboard = xmalloc (sizeof (KBOARD)); | 10118 | terminal->kboard = xmalloc (sizeof *terminal->kboard); |
| 10120 | init_kboard (terminal->kboard); | 10119 | init_kboard (terminal->kboard); |
| 10121 | KVAR (terminal->kboard, Vwindow_system) = Qx; | 10120 | KVAR (terminal->kboard, Vwindow_system) = Qx; |
| 10122 | 10121 | ||
| @@ -10370,8 +10369,8 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 10370 | const int atom_count = sizeof (atom_refs) / sizeof (atom_refs[0]); | 10369 | const int atom_count = sizeof (atom_refs) / sizeof (atom_refs[0]); |
| 10371 | /* 1 for _XSETTINGS_SN */ | 10370 | /* 1 for _XSETTINGS_SN */ |
| 10372 | const int total_atom_count = 1 + atom_count; | 10371 | const int total_atom_count = 1 + atom_count; |
| 10373 | Atom *atoms_return = xmalloc (sizeof (Atom) * total_atom_count); | 10372 | Atom *atoms_return = xmalloc (total_atom_count * sizeof *atoms_return); |
| 10374 | char **atom_names = xmalloc (sizeof (char *) * total_atom_count); | 10373 | char **atom_names = xmalloc (total_atom_count * sizeof *atom_names); |
| 10375 | static char const xsettings_fmt[] = "_XSETTINGS_S%d"; | 10374 | static char const xsettings_fmt[] = "_XSETTINGS_S%d"; |
| 10376 | char xsettings_atom_name[sizeof xsettings_fmt - 2 | 10375 | char xsettings_atom_name[sizeof xsettings_fmt - 2 |
| 10377 | + INT_STRLEN_BOUND (int)]; | 10376 | + INT_STRLEN_BOUND (int)]; |
| @@ -10399,7 +10398,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 10399 | 10398 | ||
| 10400 | dpyinfo->x_dnd_atoms_size = 8; | 10399 | dpyinfo->x_dnd_atoms_size = 8; |
| 10401 | dpyinfo->x_dnd_atoms_length = 0; | 10400 | dpyinfo->x_dnd_atoms_length = 0; |
| 10402 | dpyinfo->x_dnd_atoms = xmalloc (sizeof (*dpyinfo->x_dnd_atoms) | 10401 | dpyinfo->x_dnd_atoms = xmalloc (sizeof *dpyinfo->x_dnd_atoms |
| 10403 | * dpyinfo->x_dnd_atoms_size); | 10402 | * dpyinfo->x_dnd_atoms_size); |
| 10404 | 10403 | ||
| 10405 | dpyinfo->net_supported_atoms = NULL; | 10404 | dpyinfo->net_supported_atoms = NULL; |