Skip to content
Snippets Groups Projects
Commit eaaa2683 authored by Marek Vavruša's avatar Marek Vavruša
Browse files

utils: auto_fclose cleanup

parent e7d06f78
Branches
Tags
No related merge requests found
......@@ -23,6 +23,11 @@ void _cleanup_close(int *p)
if (*p > 0) close(*p);
}
void _cleanup_fclose(FILE **p)
{
if (*p) fclose(*p);
}
char* kr_strcatdup(unsigned n, ...)
{
/* Calculate total length */
......
......@@ -16,6 +16,8 @@
#pragma once
#include <stdio.h>
/*
* General-purpose attributes.
*/
......@@ -23,6 +25,8 @@
extern void _cleanup_free(char **p);
#define auto_close __attribute__((cleanup(_cleanup_close)))
extern void _cleanup_close(int *p);
#define auto_fclose __attribute__((cleanup(_cleanup_fclose)))
extern void _cleanup_fclose(FILE **p);
/*
* Defines.
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment