Skip to content
Snippets Groups Projects
Commit 43f33e35 authored by Jan Včelák's avatar Jan Včelák :rocket:
Browse files

[dnssec] improve automatic cleanup functions

parent 7df2a616
Branches
Tags
1 merge request!332libdnssec
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
static inline void fclose_ptr(FILE **handle)
{
fclose(*handle);
}
#define _public_ __attribute__((visibility("default")))
#define _hidden_ __attribute__((visibility("hidden")))
#define _unused_ __attribute__((unused))
#define _cleanup_(var) __attribute__((cleanup(var)))
#define _destructor_ __attribute__((destructor))
#define _cleanup_free_ _cleanup_(free)
#define _cleanup_fclose_ _cleanup_(fclose_ptr)
static inline void close_ptr(int *ptr)
{
if (*ptr != -1) {
close(*ptr);
}
}
static inline void fclose_ptr(FILE **ptr)
{
if (*ptr) {
fclose(*ptr);
}
}
#define _public_ __attribute__((visibility("default")))
#define _hidden_ __attribute__((visibility("hidden")))
static inline void free_ptr(void *ptr)
{
free(*(void **)ptr);
}
#define _cleanup_free_ _cleanup_(free_ptr)
#define _cleanup_fclose_ _cleanup_(fclose_ptr)
#define _cleanup_fclose_ _cleanup_(fclose_ptr)
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