summaryrefslogtreecommitdiff
path: root/video-buffers.c
blob: f5dc6ecece2351b21d550fc5c95e4e2e9a01be9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Video buffers
 *
 * Copyright (C) 2018 Laurent Pinchart
 *
 * Contact: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
 */

#include "video-buffers.h"

#include <stdlib.h>
#include <string.h>

struct video_buffer_set *video_buffer_set_new(unsigned int nbufs)
{
	struct video_buffer_set *buffers;

	buffers = malloc(sizeof *buffers);
	if (!buffers)
		return NULL;

	buffers->nbufs = nbufs;
	buffers->buffers = calloc(nbufs, sizeof *buffers->buffers);
	if (!buffers->buffers) {
		free(buffers);
		return NULL;
	}

	return buffers;
}

void video_buffer_set_delete(struct video_buffer_set *buffers)
{
	if (!buffers)
		return;

	free(buffers->buffers);
	free(buffers);
}