From 77f88bd146b1ce10d405c7812bdd2c4d78857bd4 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 22 Jan 2025 18:42:14 -0500 Subject: Factor out puglIsValidSize() --- src/internal.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/internal.c') diff --git a/src/internal.c b/src/internal.c index 3799e97..31345f3 100644 --- a/src/internal.c +++ b/src/internal.c @@ -18,6 +18,12 @@ puglIsValidPosition(const int x, const int y) return x >= INT16_MIN && x <= INT16_MAX && y >= INT16_MIN && y <= INT16_MAX; } +bool +puglIsValidSize(const unsigned width, const unsigned height) +{ + return width && height && width <= INT16_MAX && height <= INT16_MAX; +} + bool puglIsValidArea(const PuglArea size) { @@ -80,8 +86,7 @@ puglStoreSizeHint(PuglView* const view, const unsigned width, const unsigned height) { - if (width > INT16_MAX || height > INT16_MAX || - (unsigned)hint >= PUGL_NUM_SIZE_HINTS) { + if (!puglIsValidSize(width, height)) { return PUGL_BAD_PARAMETER; } -- cgit v1.2.1