emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Enlarge MAX_ALLOCA?


From: Eli Zaretskii
Subject: Re: Enlarge MAX_ALLOCA?
Date: Thu, 19 Jun 2014 19:48:06 +0300

> From: David Kastrup <address@hidden>
> Date: Thu, 19 Jun 2014 18:23:26 +0200
> 
> Eli Zaretskii <address@hidden> writes:
> 
> > -#define SAFE_ALLOCA(size) ((size) < MAX_ALLOCA     \
> > +#define SAFE_ALLOCA(size) ((size) <= MAX_ALLOCA    \
> >                        ? alloca (size)      \
> >                        : (sa_must_free = true, record_xmalloc (size)))
> >  
> > @@ -4469,7 +4469,7 @@ extern void *record_xmalloc (size_t) ATT
> >  
> >  #define SAFE_ALLOCA_LISP(buf, nelt)                               \
> >    do {                                                            \
> > -    if ((nelt) < MAX_ALLOCA / word_size)                  \
> > +    if ((nelt) <= MAX_ALLOCA / word_size)                 \
> >        (buf) = alloca ((nelt) * word_size);                \
> >      else if ((nelt) < min (PTRDIFF_MAX, SIZE_MAX) / word_size) \
> >        {                                                           \
> 
> Bad idea to change < to <= here.

The original macros were inconsistent: some used < and some <=, so I
changed them.

> If there is a hard limit due to short offsets or similar (and if
> there weren't, why bother at all?), then allocating a full 64kB
> might be a bad idea.

Is there really such a system?  If so, which one?  And why would that
be a worse idea than to allocate the same 64KB off the heap (which is
what that macro does in the 'else' clause?  What am I missing?

> 64kB feels arbitrary.

I explained my rationale for choosing this value.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]