libgrapheme

Freestanding C library for unicode string handling
git clone https://git.sinitax.com/suckless/libgrapheme
Log | Files | Refs | README | LICENSE | sfeed.txt

commit 25d89e6e460e68329e7a3f388fe3e150a8f5474a
parent d6bdaa7d2bfb57e798bc3669135479310c77834c
Author: Laslo Hunhold <dev@frign.de>
Date:   Sun, 31 Jul 2022 11:46:48 +0200

Use (size_t)(-1) instead of SIZE_MAX and fix style

SIZE_MAX cannot be relied upon to fully reflect size_t's size. A
portable idiom is to simply cast -1 to size_t to get the type's maximum
value.

Signed-off-by: Laslo Hunhold <dev@frign.de>

Diffstat:
Mgen/util.c | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gen/util.c b/gen/util.c @@ -34,11 +34,12 @@ struct break_test_payload static void * reallocate_array(void *p, size_t len, size_t size) { - if (len > 0 && size > SIZE_MAX/len) { + if (len > 0 && size > (size_t)(-1) / len) { errno = ENOMEM; return NULL; } - return realloc(p, len*size); + + return realloc(p, len * size); } int