mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-06-14 12:31:25 +00:00
New function memory_full_up
* src/alloc.c (memory_full_up): New function. Replace all callers of memory_full (SIZE_MAX) with callers to this function. This simplifies callers and should make future changes easier. It also saves a whopping 296 bytes in executable size with gcc 16.1.1 20260515 (Red Hat 16.1.1-2) x86-64.
This commit is contained in:
parent
a96fc7d546
commit
1eb2e052bb
36 changed files with 71 additions and 60 deletions
24
src/alloc.c
24
src/alloc.c
|
|
@ -711,7 +711,7 @@ xnmalloc (ptrdiff_t nitems, ptrdiff_t item_size)
|
|||
eassert (0 <= nitems && 0 < item_size);
|
||||
ptrdiff_t nbytes;
|
||||
if (ckd_mul (&nbytes, nitems, item_size) || SIZE_MAX < nbytes)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
return xmalloc (nbytes);
|
||||
}
|
||||
|
||||
|
|
@ -725,7 +725,7 @@ xnrealloc (void *pa, ptrdiff_t nitems, ptrdiff_t item_size)
|
|||
eassert (0 <= nitems && 0 < item_size);
|
||||
ptrdiff_t nbytes;
|
||||
if (ckd_mul (&nbytes, nitems, item_size) || SIZE_MAX < nbytes)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
return xrealloc (pa, nbytes);
|
||||
}
|
||||
|
||||
|
|
@ -792,7 +792,7 @@ xpalloc (void *pa, ptrdiff_t *nitems, ptrdiff_t nitems_incr_min,
|
|||
&& (ckd_add (&n, n0, nitems_incr_min)
|
||||
|| (0 <= nitems_max && nitems_max < n)
|
||||
|| ckd_mul (&nbytes, n, item_size)))
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
pa = xrealloc (pa, nbytes);
|
||||
*nitems = n;
|
||||
return pa;
|
||||
|
|
@ -1111,7 +1111,7 @@ lisp_align_malloc (size_t nbytes, enum mem_type type)
|
|||
{
|
||||
lisp_malloc_loser = base;
|
||||
free (base);
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -2181,7 +2181,7 @@ LENGTH must be a number. INIT matters only in whether it is t or nil. */)
|
|||
CHECK_FIXNAT (length);
|
||||
EMACS_INT len = XFIXNAT (length);
|
||||
if (BOOL_VECTOR_LENGTH_MAX < len)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
Lisp_Object val = make_clear_bool_vector (len, NILP (init));
|
||||
return NILP (init) ? val : bool_vector_fill (val, init);
|
||||
}
|
||||
|
|
@ -2193,7 +2193,7 @@ usage: (bool-vector &rest OBJECTS) */)
|
|||
(ptrdiff_t nargs, Lisp_Object *args)
|
||||
{
|
||||
if (BOOL_VECTOR_LENGTH_MAX < nargs)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
Lisp_Object vector = make_clear_bool_vector (nargs, true);
|
||||
for (ptrdiff_t i = 0; i < nargs; i++)
|
||||
if (!NILP (args[i]))
|
||||
|
|
@ -3397,7 +3397,7 @@ allocate_clear_vector (ptrdiff_t len, bool clearit)
|
|||
if (len == 0)
|
||||
return XVECTOR (zero_vector);
|
||||
if (VECTOR_ELTS_MAX < len)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
struct Lisp_Vector *v = allocate_vectorlike (len, clearit);
|
||||
v->header.size = len;
|
||||
return v;
|
||||
|
|
@ -4142,6 +4142,16 @@ memory_full (size_t nbytes)
|
|||
xsignal (Qnil, Vmemory_signal_data);
|
||||
}
|
||||
|
||||
/* Report memory exhaustion because size calculations overflowed,
|
||||
or perhaps malloc was invoked successfully but the
|
||||
resulting pointer had problems fitting into a tagged EMACS_INT. */
|
||||
|
||||
void
|
||||
memory_full_up (void)
|
||||
{
|
||||
memory_full (SIZE_MAX);
|
||||
}
|
||||
|
||||
/* If we released our reserve (due to running out of memory),
|
||||
and we have a fair amount free once again,
|
||||
try to set aside another reserve in case we run out once more.
|
||||
|
|
|
|||
|
|
@ -4948,7 +4948,7 @@ android_get_image (android_drawable handle,
|
|||
(size_t) bitmap_info.height))
|
||||
{
|
||||
ANDROID_DELETE_LOCAL_REF (bitmap);
|
||||
memory_full (0);
|
||||
memory_full_up ();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -618,7 +618,7 @@ does not have any corresponding data. In that case, use
|
|||
|
||||
if (ckd_add (&length, length, rc)
|
||||
|| PTRDIFF_MAX - length < BUFSIZ)
|
||||
memory_full (PTRDIFF_MAX);
|
||||
memory_full_up ();
|
||||
|
||||
if (rc < 0)
|
||||
return unbind_to (ref, Qnil);
|
||||
|
|
|
|||
|
|
@ -6831,7 +6831,7 @@ android_term_init (void)
|
|||
static char const at[] = " at ";
|
||||
ptrdiff_t nbytes = sizeof (title) + sizeof (at);
|
||||
if (ckd_add (&nbytes, nbytes, SBYTES (system_name)))
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
dpyinfo->x_id_name = xmalloc (nbytes);
|
||||
sprintf (dpyinfo->x_id_name, "%s%s%s", title, at,
|
||||
SDATA (system_name));
|
||||
|
|
|
|||
|
|
@ -3413,7 +3413,7 @@ record_overlay_string (struct sortstrlist *ssl, Lisp_Object str,
|
|||
nbytes = SBYTES (str);
|
||||
|
||||
if (ckd_add (&nbytes, nbytes, ssl->bytes))
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
ssl->bytes = nbytes;
|
||||
|
||||
if (STRINGP (str2))
|
||||
|
|
@ -3427,7 +3427,7 @@ record_overlay_string (struct sortstrlist *ssl, Lisp_Object str,
|
|||
nbytes = SBYTES (str2);
|
||||
|
||||
if (ckd_add (&nbytes, nbytes, ssl->bytes))
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
ssl->bytes = nbytes;
|
||||
}
|
||||
}
|
||||
|
|
@ -3499,7 +3499,7 @@ overlay_strings (ptrdiff_t pos, struct window *w, unsigned char **pstr)
|
|||
ptrdiff_t total;
|
||||
|
||||
if (ckd_add (&total, overlay_heads.bytes, overlay_tails.bytes))
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
if (total > overlay_str_len)
|
||||
overlay_str_buf = xpalloc (overlay_str_buf, &overlay_str_len,
|
||||
total - overlay_str_len, -1, 1);
|
||||
|
|
|
|||
|
|
@ -431,7 +431,7 @@ invoke it (via an `interactive' spec that contains, for instance, an
|
|||
|
||||
if (MOST_POSITIVE_FIXNUM < min (PTRDIFF_MAX, SIZE_MAX) / word_size
|
||||
&& MOST_POSITIVE_FIXNUM < nargs)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
|
||||
/* ARGS will contain the array of arguments to pass to the function.
|
||||
VISARGS will contain the same list but in a nicer form, so that if we
|
||||
|
|
|
|||
|
|
@ -2166,7 +2166,7 @@ usage: (ccl-execute-on-string CCL-PROGRAM STATUS STRING &optional CONTINUE UNIBY
|
|||
outbufsize = str_bytes;
|
||||
if (ckd_mul (&outbufsize, outbufsize, buf_magnification)
|
||||
|| ckd_add (&outbufsize, outbufsize, 256))
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
outp = outbuf = xmalloc (outbufsize);
|
||||
|
||||
consumed_chars = consumed_bytes = 0;
|
||||
|
|
|
|||
|
|
@ -7045,7 +7045,7 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table,
|
|||
ptrdiff_t dst_size;
|
||||
if (ckd_mul (&dst_size, to_nchars, MAX_MULTIBYTE_LENGTH)
|
||||
|| ckd_add (&dst_size, dst_size, buf_end - buf))
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
dst = alloc_destination (coding, dst_size, dst);
|
||||
if (EQ (coding->src_object, coding->dst_object)
|
||||
/* Input and output are not C buffers, which are safe to
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ get_composition_id (ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t nchars,
|
|||
: ASIZE (key));
|
||||
|
||||
if (GLYPH_LEN_MAX < glyph_len)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
|
||||
/* Register the composition in composition_table. */
|
||||
cmp = xmalloc (sizeof *cmp);
|
||||
|
|
|
|||
|
|
@ -1403,7 +1403,7 @@ realloc_glyph_pool (struct glyph_pool *pool, struct dim matrix_dim)
|
|||
|
||||
/* Enlarge the glyph pool. */
|
||||
if (ckd_mul (&needed, matrix_dim.height, matrix_dim.width))
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
if (needed > pool->nglyphs)
|
||||
{
|
||||
ptrdiff_t old_nglyphs = pool->nglyphs;
|
||||
|
|
@ -5412,7 +5412,7 @@ scrolling_window (struct window *w, int tab_line_p)
|
|||
- next_almost_prime_increment_max);
|
||||
ptrdiff_t current_nrows_max = row_table_max - desired_matrix->nrows;
|
||||
if (current_nrows_max < current_matrix->nrows)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
}
|
||||
|
||||
/* Reallocate vectors, tables etc. if necessary. */
|
||||
|
|
|
|||
|
|
@ -2080,7 +2080,7 @@ a buffer or a string. But this is deprecated. */)
|
|||
ptrdiff_t bytes_needed;
|
||||
if (ckd_mul (&bytes_needed, diags, 2 * sizeof *buffer)
|
||||
|| ckd_add (&bytes_needed, bytes_needed, del_bytes + ins_bytes))
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
USE_SAFE_ALLOCA;
|
||||
buffer = SAFE_ALLOCA (bytes_needed);
|
||||
unsigned char *deletions_insertions = memset (buffer + 2 * diags, 0,
|
||||
|
|
@ -3510,7 +3510,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
|
|||
v |= ckd_add (&alloca_size, info_size, format_and_discarded_size);
|
||||
v |= SIZE_MAX < alloca_size;
|
||||
if (v)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
/* The info table. */
|
||||
info = SAFE_ALLOCA (alloca_size);
|
||||
/* A copy of the format string's bytes, needed because the original
|
||||
|
|
|
|||
|
|
@ -1601,7 +1601,7 @@ internal_lisp_condition_case (Lisp_Object var, Lisp_Object bodyform,
|
|||
SAFE_ALLOCA won't work here due to the setjmp, so impose a
|
||||
MAX_ALLOCA limit. */
|
||||
if (MAX_ALLOCA / word_size < clausenb)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
Lisp_Object volatile *clauses = alloca (clausenb * sizeof *clauses);
|
||||
clauses += clausenb;
|
||||
*--clauses = make_fixnum (0);
|
||||
|
|
|
|||
|
|
@ -902,7 +902,7 @@ concat_to_string (ptrdiff_t nargs, Lisp_Object *args)
|
|||
|
||||
result_len += len;
|
||||
if (MOST_POSITIVE_FIXNUM < result_len)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
}
|
||||
|
||||
if (dest_multibyte && some_unibyte)
|
||||
|
|
@ -1122,7 +1122,7 @@ concat_to_vector (ptrdiff_t nargs, Lisp_Object *args)
|
|||
EMACS_INT len = XFIXNAT (Flength (arg));
|
||||
result_len += len;
|
||||
if (MOST_POSITIVE_FIXNUM < result_len)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
}
|
||||
|
||||
/* Create the output vector. */
|
||||
|
|
@ -4672,7 +4672,7 @@ larger_vector (Lisp_Object vec, ptrdiff_t incr_min, ptrdiff_t nitems_max)
|
|||
incr_max = n_max - old_size;
|
||||
incr = max (incr_min, min (old_size >> 1, incr_max));
|
||||
if (incr_max < incr)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
new_size = old_size + incr;
|
||||
v = allocate_vector (new_size);
|
||||
memcpy (v->contents, XVECTOR (vec)->contents, old_size * sizeof *v->contents);
|
||||
|
|
|
|||
|
|
@ -2424,7 +2424,7 @@ gnutls_symmetric_aead (bool encrypting, gnutls_cipher_algorithm_t gca,
|
|||
ptrdiff_t tagged_size;
|
||||
if (ckd_add (&tagged_size, isize, cipher_tag_size)
|
||||
|| SIZE_MAX < tagged_size)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
size_t storage_length = tagged_size;
|
||||
USE_SAFE_ALLOCA;
|
||||
char *storage = SAFE_ALLOCA (storage_length);
|
||||
|
|
|
|||
|
|
@ -698,7 +698,7 @@ get_utf8_string (const char *str)
|
|||
if (ckd_mul (&alloc, nr_bad, 4)
|
||||
|| ckd_add (&alloc, alloc, len + 1)
|
||||
|| SIZE_MAX < alloc)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
up = utf8_str = xmalloc (alloc);
|
||||
p = (unsigned char *)str;
|
||||
|
||||
|
|
@ -4382,7 +4382,7 @@ xg_store_widget_in_map (GtkWidget *w)
|
|||
{
|
||||
ptrdiff_t new_size;
|
||||
if (TYPE_MAXIMUM (Window) - ID_TO_WIDGET_INCR < id_to_widget.max_size)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
|
||||
new_size = id_to_widget.max_size + ID_TO_WIDGET_INCR;
|
||||
id_to_widget.widgets = xnrealloc (id_to_widget.widgets,
|
||||
|
|
|
|||
|
|
@ -2025,7 +2025,7 @@ haiku_create_colored_cursor (struct user_cursor_bitmap_info *info,
|
|||
bitmap = BBitmap_new (width, height, false);
|
||||
|
||||
if (!bitmap)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
|
||||
for (y = 0; y < height; ++y)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1033,7 +1033,7 @@ haikufont_shape (Lisp_Object lgstring, Lisp_Object direction)
|
|||
len = i;
|
||||
|
||||
if (INT_MAX / 2 < len)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
|
||||
block_input ();
|
||||
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ haiku_message_to_lisp (void *message)
|
|||
case 'MSGG':
|
||||
msg = be_get_message_message (message, name, j);
|
||||
if (!msg)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
t1 = haiku_message_to_lisp (msg);
|
||||
BMessage_delete (msg);
|
||||
|
||||
|
|
@ -270,7 +270,7 @@ haiku_message_to_lisp (void *message)
|
|||
}
|
||||
|
||||
if (!pbuf)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
|
||||
t1 = DECODE_FILE (build_string (pbuf));
|
||||
|
||||
|
|
@ -837,7 +837,7 @@ haiku_report_system_error (status_t code, const char *format)
|
|||
break;
|
||||
|
||||
case B_NO_MEMORY:
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -2909,7 +2909,7 @@ haiku_define_fringe_bitmap (int which, unsigned short *bits,
|
|||
block_input ();
|
||||
fringe_bmps[which] = BBitmap_new (wd, h, 1);
|
||||
if (!fringe_bmps[which])
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
BBitmap_import_fringe_bitmap (fringe_bmps[which], bits, wd, h);
|
||||
unblock_input ();
|
||||
}
|
||||
|
|
@ -4526,7 +4526,7 @@ haiku_term_init (void)
|
|||
nbytes = sizeof "GNU Emacs" + sizeof " at ";
|
||||
|
||||
if (ckd_add (&nbytes, nbytes, SBYTES (system_name)))
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
|
||||
name_buffer = alloca (nbytes);
|
||||
sprintf (name_buffer, "%s%s%s", "GNU Emacs",
|
||||
|
|
|
|||
|
|
@ -6950,7 +6950,7 @@ image_to_emacs_colors (struct frame *f, struct image *img, bool rgb_p)
|
|||
if (ckd_mul (&nbytes, sizeof *colors, img->width)
|
||||
|| ckd_mul (&nbytes, nbytes, img->height)
|
||||
|| SIZE_MAX < nbytes)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
colors = xmalloc (nbytes);
|
||||
|
||||
/* Get the X image or create a memory device context for IMG. */
|
||||
|
|
@ -7100,7 +7100,7 @@ image_detect_edges (struct frame *f, struct image *img,
|
|||
|
||||
if (ckd_mul (&nbytes, sizeof *new, img->width)
|
||||
|| ckd_mul (&nbytes, nbytes, img->height))
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
new = xmalloc (nbytes);
|
||||
|
||||
for (y = 0; y < img->height; ++y)
|
||||
|
|
@ -8486,7 +8486,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
|
|||
/* Allocate memory for the image. */
|
||||
if (ckd_mul (&nbytes, row_bytes, sizeof *pixels)
|
||||
|| ckd_mul (&nbytes, nbytes, height))
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
c->pixels = pixels = xmalloc (nbytes);
|
||||
c->rows = rows = xmalloc (height * sizeof *rows);
|
||||
for (i = 0; i < height; ++i)
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ make_symset_table (int bits, struct symset_tbl *up)
|
|||
{
|
||||
int maxbits = min (SIZE_WIDTH - 2 - (word_size < 8 ? 2 : 3), 32);
|
||||
if (bits > maxbits)
|
||||
memory_full (PTRDIFF_MAX); /* Will never happen in practice. */
|
||||
memory_full_up (); /* Will never happen in practice. */
|
||||
struct symset_tbl *st = xmalloc (sizeof *st + (sizeof *st->entries << bits));
|
||||
st->up = up;
|
||||
ptrdiff_t size = symset_size (bits);
|
||||
|
|
|
|||
|
|
@ -2109,7 +2109,7 @@ For an approximate inverse of this, see `kbd'. */)
|
|||
/* This has one extra element at the end that we don't pass to Fconcat. */
|
||||
ptrdiff_t size4;
|
||||
if (ckd_mul (&size4, nkeys + nprefix, 4))
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
SAFE_ALLOCA_LISP (args, size4);
|
||||
|
||||
/* In effect, this computes
|
||||
|
|
|
|||
|
|
@ -4430,6 +4430,7 @@ extern void parse_str_as_multibyte (const unsigned char *, ptrdiff_t,
|
|||
extern intptr_t garbage_collection_inhibited;
|
||||
extern void malloc_warning (const char *);
|
||||
extern AVOID memory_full (size_t);
|
||||
extern AVOID memory_full_up (void);
|
||||
extern AVOID buffer_memory_full (ptrdiff_t);
|
||||
extern bool survives_gc_p (Lisp_Object);
|
||||
extern void mark_object (Lisp_Object);
|
||||
|
|
@ -5704,7 +5705,7 @@ safe_free_unbind_to (specpdl_ref count, specpdl_ref sa_count, Lisp_Object val)
|
|||
ptrdiff_t alloca_nbytes; \
|
||||
if (ckd_mul (&alloca_nbytes, nelt, word_size) \
|
||||
|| SIZE_MAX < alloca_nbytes) \
|
||||
memory_full (SIZE_MAX); \
|
||||
memory_full_up (); \
|
||||
else if (alloca_nbytes <= sa_avail) \
|
||||
(buf) = AVAIL_ALLOCA (alloca_nbytes); \
|
||||
else \
|
||||
|
|
|
|||
|
|
@ -3119,7 +3119,7 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no
|
|||
len = i;
|
||||
|
||||
if (INT_MAX / 2 < len)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
|
||||
unichars = alloca (sizeof (UniChar) * (len + nonbmp_len));
|
||||
nonbmp_indices = alloca (sizeof (CFIndex) * (nonbmp_len + 1));
|
||||
|
|
|
|||
|
|
@ -1484,7 +1484,7 @@ is false when (FROM > 0 || TO < S->nchars). */
|
|||
len = i;
|
||||
|
||||
if (INT_MAX / 2 < len)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
|
||||
block_input ();
|
||||
|
||||
|
|
|
|||
|
|
@ -7150,7 +7150,7 @@ pgtk_term_init (Lisp_Object display_name, char *resource_name)
|
|||
Lisp_Object system_name = Fsystem_name ();
|
||||
ptrdiff_t nbytes;
|
||||
if (ckd_add (&nbytes, SBYTES (Vinvocation_name), SBYTES (system_name) + 2))
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
dpyinfo->x_id = ++x_display_id;
|
||||
dpyinfo->x_id_name = xmalloc (nbytes);
|
||||
char *nametail = lispstpcpy (dpyinfo->x_id_name, Vinvocation_name);
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ static size_t max_scanline_buffer_size;
|
|||
size_t _size; \
|
||||
\
|
||||
if (ckd_mul (&_size, height, stride)) \
|
||||
memory_full (SIZE_MAX); \
|
||||
memory_full_up (); \
|
||||
\
|
||||
if (_size < MAX_ALLOCA) \
|
||||
(buffer) = alloca (_size); \
|
||||
|
|
@ -113,7 +113,7 @@ static size_t max_scanline_buffer_size;
|
|||
void *_temp; \
|
||||
\
|
||||
if (ckd_mul (&_size, height, stride)) \
|
||||
memory_full (SIZE_MAX); \
|
||||
memory_full_up (); \
|
||||
\
|
||||
if (_size > scanline_buffer.buffer_size) \
|
||||
{ \
|
||||
|
|
|
|||
|
|
@ -613,7 +613,7 @@ sfnt_parse_languages (struct sfnt_meta_table *meta,
|
|||
/* Now copy metadata and add a trailing NULL byte. */
|
||||
|
||||
if (map.data_length >= SIZE_MAX)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
|
||||
metadata = SAFE_ALLOCA ((size_t) map.data_length + 1);
|
||||
memcpy (metadata, data, map.data_length);
|
||||
|
|
|
|||
|
|
@ -554,7 +554,7 @@ encode_terminal_code (struct glyph *src, int src_len,
|
|||
Vglyph_table contains a string or a composite glyph is
|
||||
encountered. */
|
||||
if (ckd_mul (&required, src_len, MAX_MULTIBYTE_LENGTH))
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
if (encode_terminal_src_size < required)
|
||||
encode_terminal_src = xpalloc (encode_terminal_src,
|
||||
&encode_terminal_src_size,
|
||||
|
|
@ -1245,7 +1245,7 @@ calculate_costs (struct frame *frame)
|
|||
max_frame_cols = max (max_frame_cols, FRAME_COLS (frame));
|
||||
if ((min (PTRDIFF_MAX, SIZE_MAX) / sizeof (int) - 1) / 2
|
||||
< max_frame_cols)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
|
||||
char_ins_del_vector =
|
||||
xrealloc (char_ins_del_vector,
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ emacs_localtime_rz (timezone_t tz, time_t const *t, struct tm *tm)
|
|||
#endif
|
||||
tm = localtime_rz (tz, t, tm);
|
||||
if (!tm && errno == ENOMEM)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
return tm;
|
||||
}
|
||||
|
||||
|
|
@ -317,7 +317,7 @@ tzlookup (Lisp_Object zone, bool settz)
|
|||
if (!new_tz)
|
||||
{
|
||||
if (errno == ENOMEM)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
invalid_time_zone_specification (zone);
|
||||
}
|
||||
}
|
||||
|
|
@ -367,7 +367,7 @@ time_error (int err)
|
|||
{
|
||||
switch (err)
|
||||
{
|
||||
case ENOMEM: memory_full (SIZE_MAX);
|
||||
case ENOMEM: memory_full_up ();
|
||||
case EOVERFLOW: time_overflow ();
|
||||
default: time_spec_invalid ();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ tparam1 (const char *string, char *outstring, int len,
|
|||
else
|
||||
doleft++, append_len_incr = strlen (left);
|
||||
if (ckd_add (&append_len, append_len, append_len_incr))
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
}
|
||||
}
|
||||
*op++ = tem ? tem : 0200;
|
||||
|
|
|
|||
|
|
@ -7820,7 +7820,7 @@ w32_initialize_display_info (Lisp_Object display_name)
|
|||
static char const at[] = " at ";
|
||||
ptrdiff_t nbytes = sizeof (title) + sizeof (at);
|
||||
if (ckd_add (&nbytes, nbytes, SCHARS (Vsystem_name)))
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
dpyinfo->w32_id_name = xmalloc (nbytes);
|
||||
sprintf (dpyinfo->w32_id_name, "%s%s%s", title, at, SDATA (Vsystem_name));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1882,7 +1882,7 @@ x_get_window_property (Display *display, Window window, Atom property,
|
|||
if (data)
|
||||
xfree (data);
|
||||
unblock_input ();
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
}
|
||||
|
||||
/* Use xfree, not XFree, to free the data obtained with this function. */
|
||||
|
|
@ -1903,7 +1903,7 @@ receive_incremental_selection (struct x_display_info *dpyinfo,
|
|||
Display *display = dpyinfo->display;
|
||||
|
||||
if (min (PTRDIFF_MAX, SIZE_MAX) < min_size_bytes)
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
*data_ret = xmalloc (min_size_bytes);
|
||||
*size_bytes_ret = min_size_bytes;
|
||||
|
||||
|
|
@ -3063,7 +3063,7 @@ x_property_data_to_lisp (struct frame *f, const unsigned char *data,
|
|||
ptrdiff_t format_bytes = format >> 3;
|
||||
ptrdiff_t data_bytes;
|
||||
if (ckd_mul (&data_bytes, size, format_bytes))
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
return selection_data_to_lisp_data (FRAME_DISPLAY_INFO (f), data,
|
||||
data_bytes, type, format);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ smc_save_yourself_CB (SmcConn smcConn,
|
|||
props[props_idx]->type = xstrdup (SmLISTofARRAY8);
|
||||
/* /path/to/emacs, --smid=xxx --no-splash --chdir=dir ... */
|
||||
if (ckd_add (&i, initial_argc, 3))
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
props[props_idx]->num_vals = i;
|
||||
vp = xnmalloc (i, sizeof *vp);
|
||||
props[props_idx]->vals = vp;
|
||||
|
|
|
|||
|
|
@ -30989,7 +30989,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
|
|||
static char const at[] = " at ";
|
||||
ptrdiff_t nbytes = sizeof (title) + sizeof (at);
|
||||
if (ckd_add (&nbytes, nbytes, SBYTES (system_name)))
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
dpyinfo->x_id_name = xmalloc (nbytes);
|
||||
sprintf (dpyinfo->x_id_name, "%s%s%s", title, at, SDATA (system_name));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2462,7 +2462,7 @@ webkit_js_to_lisp (JSCValue *value)
|
|||
|
||||
Lisp_Object obj;
|
||||
if (! (0 <= dlen && dlen < G_MAXINT32))
|
||||
memory_full (SIZE_MAX);
|
||||
memory_full_up ();
|
||||
|
||||
ptrdiff_t n = dlen;
|
||||
struct Lisp_Vector *p = allocate_nil_vector (n);
|
||||
|
|
|
|||
Loading…
Reference in a new issue