diff options
author | Dmitry Antipov <dmantipov@yandex.ru> | 2012-07-03 15:09:36 +0400 |
---|---|---|
committer | Dmitry Antipov <dmantipov@yandex.ru> | 2012-07-03 15:09:36 +0400 |
commit | d12e8f5a194b64e25eb57d5f6ea19f663c0e4f2b (patch) | |
tree | e3b82f1411cf9ab9600c8aebda32c50ca89c7bb9 /src/alloc.c | |
parent | 296094c3dde63e458242a8537d1d3c0ca299dd56 (diff) | |
download | emacs-d12e8f5a194b64e25eb57d5f6ea19f663c0e4f2b.tar.gz emacs-d12e8f5a194b64e25eb57d5f6ea19f663c0e4f2b.tar.bz2 emacs-d12e8f5a194b64e25eb57d5f6ea19f663c0e4f2b.zip |
* alloc.c (allocate_vector_block): Remove redundant
calls to mallopt if DOUG_LEA_MALLOC is defined.
(allocate_vectorlike): If DOUG_LEA_MALLOC is defined,
avoid calls to mallopt if zero_vector is returned.
Diffstat (limited to 'src/alloc.c')
-rw-r--r-- | src/alloc.c | 58 |
1 files changed, 23 insertions, 35 deletions
diff --git a/src/alloc.c b/src/alloc.c index 3306bc4107b..0d4491e8472 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -2958,17 +2958,7 @@ static struct Lisp_Vector *zero_vector; static struct vector_block * allocate_vector_block (void) { - struct vector_block *block; - -#ifdef DOUG_LEA_MALLOC - mallopt (M_MMAP_MAX, 0); -#endif - - block = xmalloc (sizeof (struct vector_block)); - -#ifdef DOUG_LEA_MALLOC - mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); -#endif + struct vector_block *block = xmalloc (sizeof (struct vector_block)); #if GC_MARK_STACK && !defined GC_MALLOC_CHECK mem_insert (block->data, block->data + VECTOR_BLOCK_BYTES, @@ -3166,44 +3156,42 @@ static struct Lisp_Vector * allocate_vectorlike (ptrdiff_t len) { struct Lisp_Vector *p; - size_t nbytes; MALLOC_BLOCK_INPUT; -#ifdef DOUG_LEA_MALLOC - /* Prevent mmap'ing the chunk. Lisp data may not be mmap'ed - because mapped region contents are not preserved in - a dumped Emacs. */ - mallopt (M_MMAP_MAX, 0); -#endif - /* This gets triggered by code which I haven't bothered to fix. --Stef */ /* eassert (!handling_signal); */ if (len == 0) + p = zero_vector; + else { - MALLOC_UNBLOCK_INPUT; - return zero_vector; - } + size_t nbytes = header_size + len * word_size; - nbytes = header_size + len * word_size; +#ifdef DOUG_LEA_MALLOC + /* Prevent mmap'ing the chunk. Lisp data may not be mmap'ed + because mapped region contents are not preserved in + a dumped Emacs. */ + mallopt (M_MMAP_MAX, 0); +#endif - if (nbytes <= VBLOCK_BYTES_MAX) - p = allocate_vector_from_block (vroundup (nbytes)); - else - { - p = (struct Lisp_Vector *) lisp_malloc (nbytes, MEM_TYPE_VECTORLIKE); - p->header.next.vector = large_vectors; - large_vectors = p; - } + if (nbytes <= VBLOCK_BYTES_MAX) + p = allocate_vector_from_block (vroundup (nbytes)); + else + { + p = (struct Lisp_Vector *) lisp_malloc (nbytes, MEM_TYPE_VECTORLIKE); + p->header.next.vector = large_vectors; + large_vectors = p; + } #ifdef DOUG_LEA_MALLOC - /* Back to a reasonable maximum of mmap'ed areas. */ - mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); + /* Back to a reasonable maximum of mmap'ed areas. */ + mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); #endif - consing_since_gc += nbytes; - vector_cells_consed += len; + consing_since_gc += nbytes; + vector_cells_consed += len; + } MALLOC_UNBLOCK_INPUT; |