aboutsummaryrefslogtreecommitdiffstats
path: root/libskrift_open_font_mem.c
blob: 3828546aa98882929d6dceb3cefdec9d08972f21 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* See LICENSE file for copyright and license details. */
#include "common.h"

int
libskrift_open_font_mem(LIBSKRIFT_FONT **fontp, const void *mem, size_t size)
{
	*fontp = calloc(1, sizeof(**fontp));
	if (!*fontp)
		return -1;
	(*fontp)->refcount = 1;
	(*fontp)->font = sft_loadmem(mem, size);
	if (!(*fontp)->font) {
		free(*fontp);
		*fontp = NULL;
		return -1;
	}
	return 0;
}