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
This commit is contained in:
@@ -18,10 +18,10 @@
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/relocations.h"
|
||||
#include "libc/macros.internal.h"
|
||||
.source __FILE__
|
||||
|
||||
// Loads all pages from program image into memory.
|
||||
peekall:.leafprologue
|
||||
_peekall:
|
||||
.leafprologue
|
||||
ezlea _base,si
|
||||
ezlea _end,cx
|
||||
0: mov (%rsi),%eax
|
||||
@@ -29,4 +29,4 @@ peekall:.leafprologue
|
||||
cmp %rcx,%rsi
|
||||
jb 0b
|
||||
.leafepilogue
|
||||
.endfn peekall,globl
|
||||
.endfn _peekall,globl
|
||||
|
||||
Reference in New Issue
Block a user