aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c75
1 files changed, 33 insertions, 42 deletions
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;
2972static struct vector_block * 2966static struct vector_block *
2973allocate_vector_block (void) 2967allocate_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)
3253struct buffer * 3247struct buffer *
3254allocate_buffer (void) 3248allocate_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);