def test_setjmp_noleak(self):
    src = '\n#include <setjmp.h>\n#include <stdio.h>\n#include <assert.h>\n\njmp_buf env;\n\nvoid luaWork(int d){\n  int x;\n  printf("d is at %d\\n", d);\n\n  longjmp(env, 1);\n}\n\n#include <malloc.h>\n#include <stdlib.h>\n\nvoid dump() {\n  struct mallinfo m = mallinfo();\n  printf("dump: %d , %d\\n", m.arena, m.uordblks);\n}\n\nvoid work(int n)\n{\n  printf("work %d\\n", n);\n  dump();\n\n  if(!setjmp(env)){\n    luaWork(n);\n  }\n\n  if (n > 0) work(n-1);\n}\n\nint main() {\n  struct mallinfo m1 = mallinfo();\n  dump();\n  work(10);\n  dump();\n  struct mallinfo m2 = mallinfo();\n  assert(m1.uordblks == m2.uordblks);\n  printf("ok.\\n");\n}\n'
    self.do_run(src, 'ok.')
def test_setjmp_noleak(self):
    src = '\n#include <setjmp.h>\n#include <stdio.h>\n#include <assert.h>\n\njmp_buf env;\n\nvoid luaWork(int d){\n  int x;\n  printf("d is at %d\\n", d);\n\n  longjmp(env, 1);\n}\n\n#include <malloc.h>\n#include <stdlib.h>\n\nvoid dump() {\n  struct mallinfo m = mallinfo();\n  printf("dump: %d , %d\\n", m.arena, m.uordblks);\n}\n\nvoid work(int n)\n{\n  printf("work %d\\n", n);\n  dump();\n\n  if(!setjmp(env)){\n    luaWork(n);\n  }\n\n  if (n > 0) work(n-1);\n}\n\nint main() {\n  struct mallinfo m1 = mallinfo();\n  dump();\n  work(10);\n  dump();\n  struct mallinfo m2 = mallinfo();\n  assert(m1.uordblks == m2.uordblks);\n  printf("ok.\\n");\n}\n'
    self.do_run(src, 'ok.')