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
18 lines
358 B
C
18 lines
358 B
C
int main(int argc, char *argv[]) {
|
|
int rc;
|
|
char *s;
|
|
FILE *f;
|
|
showcrashreports();
|
|
s = strdup(argv[0]);
|
|
s[0] = 'Z';
|
|
f = fopen("/dev/null", "w");
|
|
fputs(_gc(xasprintf("hello world %d %s\n", argc, s)), f);
|
|
fclose(f);
|
|
rc = system("exit 42");
|
|
CHECK_NE(-1, rc);
|
|
CHECK(WIFEXITED(rc));
|
|
CHECK_EQ(42, WEXITSTATUS(rc));
|
|
free(s);
|
|
return 0;
|
|
}
|