cosmopolitan/libc/runtime/gc.internal.h
Justine Tunney 33e8fc8687 Expose public garbage collector API for C language
You can now do epic things like this:

    puts(_gc(xasprintf("%d", 123)));

The _gc() API is shorthand for _defer() which works like Go's keyword:

    const char *s = xasprintf("%d", 123);
    _defer(free, s);
    puts(s);

Be sure to always use -fno-omit-frame-pointer which makes code fast too.

Enjoy! See also #114
2021-03-08 10:59:34 -08:00

10 lines
341 B
C

#ifndef COSMOPOLITAN_LIBC_RUNTIME_GC_INTERNAL_H_
#define COSMOPOLITAN_LIBC_RUNTIME_GC_INTERNAL_H_
#include "libc/runtime/gc.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
#define gc(THING) _gc(THING)
#define defer(FN, ARG) _defer(FN, ARG)
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_RUNTIME_GC_INTERNAL_H_ */