Mercurial > repo
view src/ploki/atechit.c @ 12500:e48c08805365 draft default tip
<b_jonas> ` learn \'The password of the month is Cthulhuquagdonic Mothraquagdonic Narwhalicorn.\' # https://logs.esolangs.org/libera-esolangs/2024-04.html#lKE Infinite craft
author | HackEso <hackeso@esolangs.org> |
---|---|
date | Wed, 01 May 2024 06:39:10 +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); } }