summaryrefslogtreecommitdiff
path: root/src/alloc.c
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2023-05-18 09:04:57 +0800
committerPo Lu <luangruo@yahoo.com>2023-05-18 09:04:57 +0800
commit074c0268fd32d6527e124cff386bb6b15cf90017 (patch)
tree62111c3c70d46a738f15514e988a707409ca45f4 /src/alloc.c
parentdb48eff8cf4a88393c0209f663ca194ee37fa747 (diff)
parent5ef169ed701fa4f850fdca5563cdd468207d5d4f (diff)
downloademacs-feature/android.tar.gz
Merge remote-tracking branch 'origin/master' into feature/androidfeature/android
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/alloc.c b/src/alloc.c
index d87cc44b59b..82b1c6b0355 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -867,7 +867,7 @@ xnmalloc (ptrdiff_t nitems, ptrdiff_t item_size)
{
eassert (0 <= nitems && 0 < item_size);
ptrdiff_t nbytes;
- if (INT_MULTIPLY_WRAPV (nitems, item_size, &nbytes) || SIZE_MAX < nbytes)
+ if (ckd_mul (&nbytes, nitems, item_size) || SIZE_MAX < nbytes)
memory_full (SIZE_MAX);
return xmalloc (nbytes);
}
@@ -881,7 +881,7 @@ xnrealloc (void *pa, ptrdiff_t nitems, ptrdiff_t item_size)
{
eassert (0 <= nitems && 0 < item_size);
ptrdiff_t nbytes;
- if (INT_MULTIPLY_WRAPV (nitems, item_size, &nbytes) || SIZE_MAX < nbytes)
+ if (ckd_mul (&nbytes, nitems, item_size) || SIZE_MAX < nbytes)
memory_full (SIZE_MAX);
return xrealloc (pa, nbytes);
}
@@ -928,13 +928,13 @@ xpalloc (void *pa, ptrdiff_t *nitems, ptrdiff_t nitems_incr_min,
NITEMS_MAX, and what the C language can represent safely. */
ptrdiff_t n, nbytes;
- if (INT_ADD_WRAPV (n0, n0 >> 1, &n))
+ if (ckd_add (&n, n0, n0 >> 1))
n = PTRDIFF_MAX;
if (0 <= nitems_max && nitems_max < n)
n = nitems_max;
ptrdiff_t adjusted_nbytes
- = ((INT_MULTIPLY_WRAPV (n, item_size, &nbytes) || SIZE_MAX < nbytes)
+ = ((ckd_mul (&nbytes, n, item_size) || SIZE_MAX < nbytes)
? min (PTRDIFF_MAX, SIZE_MAX)
: nbytes < DEFAULT_MXFAST ? DEFAULT_MXFAST : 0);
if (adjusted_nbytes)
@@ -946,9 +946,9 @@ xpalloc (void *pa, ptrdiff_t *nitems, ptrdiff_t nitems_incr_min,
if (! pa)
*nitems = 0;
if (n - n0 < nitems_incr_min
- && (INT_ADD_WRAPV (n0, nitems_incr_min, &n)
+ && (ckd_add (&n, n0, nitems_incr_min)
|| (0 <= nitems_max && nitems_max < n)
- || INT_MULTIPLY_WRAPV (n, item_size, &nbytes)))
+ || ckd_mul (&nbytes, n, item_size)))
memory_full (SIZE_MAX);
pa = xrealloc (pa, nbytes);
*nitems = n;
@@ -2379,7 +2379,7 @@ a multibyte string even if INIT is an ASCII character. */)
ptrdiff_t len = CHAR_STRING (c, str);
EMACS_INT string_len = XFIXNUM (length);
- if (INT_MULTIPLY_WRAPV (len, string_len, &nbytes))
+ if (ckd_mul (&nbytes, len, string_len))
string_overflow ();
val = make_clear_multibyte_string (string_len, nbytes, clearit);
if (!clearit)
@@ -5239,7 +5239,7 @@ mark_memory (void const *start, void const *end)
a Lisp_Object might be split into registers saved into
non-adjacent words and P might be the low-order word's value. */
intptr_t ip;
- INT_ADD_WRAPV ((intptr_t) p, (intptr_t) lispsym, &ip);
+ ckd_add (&ip, (intptr_t) p, (intptr_t) lispsym);
mark_maybe_pointer ((void *) ip, true);
}
}