From 2bb0cfbf8137e02cc32aae3b36f85ef7300e8936 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 9 Jun 2018 14:29:41 +0300 Subject: Split UVC gadget into a library and test application Split the project into a UVC gadget library and a test application. To avoid rolling out a custom build system, switch to CMake. Signed-off-by: Laurent Pinchart --- lib/video-buffers.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 lib/video-buffers.c (limited to 'lib/video-buffers.c') diff --git a/lib/video-buffers.c b/lib/video-buffers.c new file mode 100644 index 0000000..f5dc6ec --- /dev/null +++ b/lib/video-buffers.c @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Video buffers + * + * Copyright (C) 2018 Laurent Pinchart + * + * Contact: Laurent Pinchart + */ + +#include "video-buffers.h" + +#include +#include + +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); +} -- cgit v1.2.3