libansilove

Library for converting ANSI, ASCII, and other formats to PNG
Log | Files | Refs | README | LICENSE

commit f63be4ec7e2f639e42e6b8a73e58c4545a3096b4
parent 7e7535909f43acea657c9f645507eae56444b3fa
Author: Frederic Cambus <fred@statdns.com>
Date:   Fri, 26 Oct 2018 17:57:57 +0200

Add an ansilove_clean() function to free PNG data

Diffstat:
MCMakeLists.txt | 2+-
Minclude/ansilove.h | 1+
Asrc/clean.c | 27+++++++++++++++++++++++++++
3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt @@ -21,7 +21,7 @@ find_path(GD_INCLUDE_DIRS gd.h) find_library(GD_LIBRARIES NAMES gd REQUIRED) include_directories(${GD_INCLUDE_DIRS}) -set(SRC src/drawchar.c src/fonts.c src/error.c src/loadfile.c src/init.c src/output.c src/savefile.c) +set(SRC src/clean.c src/drawchar.c src/fonts.c src/error.c src/loadfile.c src/init.c src/output.c src/savefile.c) set(LOADERS src/loaders/ansi.c src/loaders/artworx.c src/loaders/binary.c src/loaders/icedraw.c src/loaders/pcboard.c src/loaders/tundra.c src/loaders/xbin.c) if(NOT HAVE_STRTONUM) diff --git a/include/ansilove.h b/include/ansilove.h @@ -87,6 +87,7 @@ int ansilove_init(struct ansilove_ctx *, struct ansilove_options *); char* ansilove_error(struct ansilove_ctx *); int ansilove_loadfile(struct ansilove_ctx *, char *); int ansilove_savefile(struct ansilove_ctx *, char *); +int ansilove_clean(struct ansilove_ctx *); int ansilove_ansi(struct ansilove_ctx *, struct ansilove_options *); int ansilove_artworx(struct ansilove_ctx *, struct ansilove_options *); diff --git a/src/clean.c b/src/clean.c @@ -0,0 +1,27 @@ +// +// clean.c +// AnsiLove/C +// +// Copyright (c) 2011-2018 Stefan Vogt, Brian Cassidy, and Frederic Cambus. +// All rights reserved. +// +// This source code is licensed under the BSD 2-Clause License. +// See the LICENSE file for details. +// + +#include <fcntl.h> +#include <unistd.h> +#include <sys/mman.h> +#include <sys/stat.h> +#include "ansilove.h" + +int +ansilove_clean(struct ansilove_ctx *ctx) { + if (ctx == NULL) + return -1; + + gdFree((void *)ctx->png.buffer); + ctx->png.length = 0; + + return 0; +}