diff options
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/alloc.c b/src/alloc.c index a8ad44491fa..f5f25d53435 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -806,8 +806,8 @@ verify (INT_MAX <= PTRDIFF_MAX); | |||
| 806 | void * | 806 | void * |
| 807 | xnmalloc (ptrdiff_t nitems, ptrdiff_t item_size) | 807 | xnmalloc (ptrdiff_t nitems, ptrdiff_t item_size) |
| 808 | { | 808 | { |
| 809 | eassert (0 <= nitems && 0 < item_size); | 809 | eassert (nitems >= 0 && item_size > 0); |
| 810 | if (min (PTRDIFF_MAX, SIZE_MAX) / item_size < nitems) | 810 | if (nitems > min (PTRDIFF_MAX, SIZE_MAX) / item_size) |
| 811 | memory_full (SIZE_MAX); | 811 | memory_full (SIZE_MAX); |
| 812 | return xmalloc (nitems * item_size); | 812 | return xmalloc (nitems * item_size); |
| 813 | } | 813 | } |
| @@ -819,8 +819,8 @@ xnmalloc (ptrdiff_t nitems, ptrdiff_t item_size) | |||
| 819 | void * | 819 | void * |
| 820 | xnrealloc (void *pa, ptrdiff_t nitems, ptrdiff_t item_size) | 820 | xnrealloc (void *pa, ptrdiff_t nitems, ptrdiff_t item_size) |
| 821 | { | 821 | { |
| 822 | eassert (0 <= nitems && 0 < item_size); | 822 | eassert (nitems >= 0 && item_size > 0); |
| 823 | if (min (PTRDIFF_MAX, SIZE_MAX) / item_size < nitems) | 823 | if (nitems > min (PTRDIFF_MAX, SIZE_MAX) / item_size) |
| 824 | memory_full (SIZE_MAX); | 824 | memory_full (SIZE_MAX); |
| 825 | return xrealloc (pa, nitems * item_size); | 825 | return xrealloc (pa, nitems * item_size); |
| 826 | } | 826 | } |
| @@ -873,10 +873,10 @@ xpalloc (void *pa, ptrdiff_t *nitems, ptrdiff_t nitems_incr_min, | |||
| 873 | ptrdiff_t nitems_incr_max = n_max - n; | 873 | ptrdiff_t nitems_incr_max = n_max - n; |
| 874 | ptrdiff_t incr = max (nitems_incr_min, min (incr_estimate, nitems_incr_max)); | 874 | ptrdiff_t incr = max (nitems_incr_min, min (incr_estimate, nitems_incr_max)); |
| 875 | 875 | ||
| 876 | eassert (0 < item_size && 0 < nitems_incr_min && 0 <= n && -1 <= nitems_max); | 876 | eassert (item_size > 0 && nitems_incr_min > 0 && n >= 0 && nitems_max >= -1); |
| 877 | if (! pa) | 877 | if (! pa) |
| 878 | *nitems = 0; | 878 | *nitems = 0; |
| 879 | if (nitems_incr_max < incr) | 879 | if (incr > nitems_incr_max) |
| 880 | memory_full (SIZE_MAX); | 880 | memory_full (SIZE_MAX); |
| 881 | n += incr; | 881 | n += incr; |
| 882 | pa = xrealloc (pa, n * item_size); | 882 | pa = xrealloc (pa, n * item_size); |
| @@ -1183,7 +1183,7 @@ lisp_align_malloc (size_t nbytes, enum mem_type type) | |||
| 1183 | } | 1183 | } |
| 1184 | ABLOCKS_BUSY (abase) = (struct ablocks *) aligned; | 1184 | ABLOCKS_BUSY (abase) = (struct ablocks *) aligned; |
| 1185 | 1185 | ||
| 1186 | eassert (0 == ((uintptr_t) abase) % BLOCK_ALIGN); | 1186 | eassert ((uintptr_t) abase % BLOCK_ALIGN == 0); |
| 1187 | eassert (ABLOCK_ABASE (&abase->blocks[3]) == abase); /* 3 is arbitrary */ | 1187 | eassert (ABLOCK_ABASE (&abase->blocks[3]) == abase); /* 3 is arbitrary */ |
| 1188 | eassert (ABLOCK_ABASE (&abase->blocks[0]) == abase); | 1188 | eassert (ABLOCK_ABASE (&abase->blocks[0]) == abase); |
| 1189 | eassert (ABLOCKS_BASE (abase) == base); | 1189 | eassert (ABLOCKS_BASE (abase) == base); |
| @@ -1205,7 +1205,7 @@ lisp_align_malloc (size_t nbytes, enum mem_type type) | |||
| 1205 | 1205 | ||
| 1206 | MALLOC_PROBE (nbytes); | 1206 | MALLOC_PROBE (nbytes); |
| 1207 | 1207 | ||
| 1208 | eassert (0 == ((uintptr_t) val) % BLOCK_ALIGN); | 1208 | eassert ((uintptr_t) val % BLOCK_ALIGN == 0); |
| 1209 | return val; | 1209 | return val; |
| 1210 | } | 1210 | } |
| 1211 | 1211 | ||
| @@ -5706,7 +5706,7 @@ garbage_collect_1 (void *end) | |||
| 5706 | double tot = total_bytes_of_live_objects (); | 5706 | double tot = total_bytes_of_live_objects (); |
| 5707 | 5707 | ||
| 5708 | tot *= XFLOAT_DATA (Vgc_cons_percentage); | 5708 | tot *= XFLOAT_DATA (Vgc_cons_percentage); |
| 5709 | if (0 < tot) | 5709 | if (tot > 0) |
| 5710 | { | 5710 | { |
| 5711 | if (tot < TYPE_MAXIMUM (EMACS_INT)) | 5711 | if (tot < TYPE_MAXIMUM (EMACS_INT)) |
| 5712 | gc_relative_threshold = tot; | 5712 | gc_relative_threshold = tot; |