aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 407ac725414..31e8da70161 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -2774,6 +2774,19 @@ DEFUN ("cons", Fcons, Scons, 2, 2, 0,
2774 { 2774 {
2775 if (cons_block_index == CONS_BLOCK_SIZE) 2775 if (cons_block_index == CONS_BLOCK_SIZE)
2776 { 2776 {
2777 /* Maximum number of conses that should be active at any
2778 given time, so that list lengths fit into a ptrdiff_t and
2779 into a fixnum. */
2780 ptrdiff_t max_conses = min (PTRDIFF_MAX, MOST_POSITIVE_FIXNUM);
2781
2782 /* This check is typically optimized away, as a runtime
2783 check is needed only on weird platforms where a count of
2784 distinct conses might not fit. */
2785 if (max_conses < INTPTR_MAX / sizeof (struct Lisp_Cons)
2786 && (max_conses - CONS_BLOCK_SIZE
2787 < total_free_conses + total_conses))
2788 memory_full (sizeof (struct cons_block));
2789
2777 struct cons_block *new 2790 struct cons_block *new
2778 = lisp_align_malloc (sizeof *new, MEM_TYPE_CONS); 2791 = lisp_align_malloc (sizeof *new, MEM_TYPE_CONS);
2779 memset (new->gcmarkbits, 0, sizeof new->gcmarkbits); 2792 memset (new->gcmarkbits, 0, sizeof new->gcmarkbits);