From 226d807bb8bc0cdbc011b2e616ac02881e74c542 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 23 Nov 2025 21:33:38 +0100 Subject: First commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libquanta_malloc_palette.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 libquanta_malloc_palette.c (limited to 'libquanta_malloc_palette.c') diff --git a/libquanta_malloc_palette.c b/libquanta_malloc_palette.c new file mode 100644 index 0000000..816fb89 --- /dev/null +++ b/libquanta_malloc_palette.c @@ -0,0 +1,21 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" + + +struct libquanta_palette * +libquanta_malloc_palette(size_t ncolours, size_t nchannels) +{ + struct libquanta_palette *ret; + size_t size; + + if (libquanta_palette_size(ncolours, nchannels, &size)) { + if (errno == EOVERFLOW) + errno = ENOMEM; + return NULL; + } + + ret = malloc(size); + if (ret) + ret->size = ncolours; + return ret; +} -- cgit v1.2.3-70-g09d2