Mercurial > repo
view src/ploki/atechit.c @ 7408:4315d5bac235
<b_jonas> slashlearn Ravnica/Ravnica: City of Guilds is a city of guilds. \xe2\x80\x9cCity of Guilds\xe2\x80\x9d is part of its name. The Wizards of the Coast Marketing Department: We Sell Anything thought players might not notice it was a City of Guilds unless they put the tagline into the name.
author | HackBot |
---|---|
date | Sun, 17 Apr 2016 19:29:52 +0000 |
parents | ac0403686959 |
children |
line wrap: on
line source
#include "zz.h" #include "atechit.h" #include "main.h" #include <stdio.h> #include <stdlib.h> enum {MAGIC = 23}; static size_t Aused; static void (*Afunc[MAGIC])(void); static void bah(void) { for (; Aused; Afunc[--Aused]()) ; } void atechit(void (*f)(void)) { if (Aused >= sizeof Afunc / sizeof *Afunc) { NOTREACHED; } Afunc[Aused++] = f; if (Aused == 1 && atexit(bah)) { fprintf(stderr, "%s: atexit(): error message\n", Prog); bah(); exit(EXIT_FAILURE); } }