From 8bbde91f62291cb0383c2406ae6123be903c944b Mon Sep 17 00:00:00 2001 From: grischka Date: Sat, 19 Dec 2009 22:11:12 +0100 Subject: tcc_relocate: revert to 0.9.24 behavior --- tests/libtcc_test.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'tests/libtcc_test.c') diff --git a/tests/libtcc_test.c b/tests/libtcc_test.c index a602fb0..5a4c800 100644 --- a/tests/libtcc_test.c +++ b/tests/libtcc_test.c @@ -36,8 +36,6 @@ int main(int argc, char **argv) { TCCState *s; int (*func)(int); - void *mem; - int size; s = tcc_new(); if (!s) { @@ -59,26 +57,20 @@ int main(int argc, char **argv) You may also open a dll with tcc_add_dll() and use symbols from that */ tcc_add_symbol(s, "add", add); - /* get needed size of the code */ - size = tcc_relocate(s, NULL); - if (size == -1) + /* relocate the code */ + if (tcc_relocate(s) < 0) return 1; - /* allocate memory and copy the code into it */ - mem = malloc(size); - tcc_relocate(s, mem); - /* get entry symbol */ func = tcc_get_symbol(s, "foo"); if (!func) return 1; - /* delete the state */ - tcc_delete(s); - /* run the code */ func(32); - free(mem); + /* delete the state */ + tcc_delete(s); + return 0; } -- cgit v1.3.1