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:
@@ -34,7 +34,7 @@ static bool IsHaltingInitialized(struct Machine *m) {
|
||||
|
||||
void HaltMachine(struct Machine *m, int code) {
|
||||
CHECK(IsHaltingInitialized(m));
|
||||
gclongjmp(m->onhalt, code);
|
||||
_gclongjmp(m->onhalt, code);
|
||||
}
|
||||
|
||||
void ThrowDivideError(struct Machine *m) {
|
||||
|
||||
@@ -1351,7 +1351,7 @@ static void OnExit(void) {
|
||||
}
|
||||
|
||||
static void MakeLatencyLittleLessBad(void) {
|
||||
peekall();
|
||||
_peekall();
|
||||
LOGIFNEG1(mlockall(MCL_CURRENT));
|
||||
LOGIFNEG1(nice(-5));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user