Skip to content

Instantly share code, notes, and snippets.

View wnkz's full-sized avatar
👻
☁️

Grégoire Morpain wnkz

👻
☁️
View GitHub Profile
@gcmurphy
gcmurphy / scoping.c
Created December 18, 2013 22:35
Things that I didn't know you could do with GNU C
#include <stdio.h>
#include <stdlib.h>
#define nil NULL
#define ScopedFile FILE * __attribute__((cleanup(fclosep)))
#define ScopedMemory void * __attribute__((cleanup(freep)))
void fclosep(FILE **f){
if (*f){
fclose(*f);