aboutsummaryrefslogtreecommitdiffstats
path: root/libquanta_malloc_palette.c
blob: 816fb89785cc62b21320ab128ad7b3d4dfcf7102 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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;
}