aboutsummaryrefslogtreecommitdiffstats
path: root/libquanta_malloc_palette.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libquanta_malloc_palette.c21
1 files changed, 21 insertions, 0 deletions
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;
+}