libansilove

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

clean.c (627B)


      1 /*
      2  * clean.c
      3  * libansilove 1.2.7
      4  * https://www.ansilove.org
      5  *
      6  * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus
      7  * All rights reserved.
      8  *
      9  * libansilove is licensed under the BSD 2-Clause License.
     10  * See LICENSE file for details.
     11  */
     12 
     13 #include <sys/mman.h>
     14 
     15 #include <stddef.h>
     16 #include "ansilove.h"
     17 #include "gd.h"
     18 
     19 int
     20 ansilove_clean(struct ansilove_ctx *ctx)
     21 {
     22 	if (ctx == NULL)
     23 		return -1;
     24 
     25 	if (ctx->png.buffer != NULL)
     26 		gdFree(ctx->png.buffer);
     27 
     28 	if (ctx->buffer != MAP_FAILED)
     29 		(void)munmap(ctx->buffer, ctx->maplen);
     30 
     31 	ctx->maplen = ctx->length = 0;
     32 	ctx->png.length = 0;
     33 
     34 	return 0;
     35 }