diff options
| author | grischka <grischka> | 2009-12-19 22:11:12 +0100 |
|---|---|---|
| committer | grischka <grischka> | 2009-12-19 22:16:23 +0100 |
| commit | 8bbde91f62291cb0383c2406ae6123be903c944b (patch) | |
| tree | ef27e46008262d2bf873c484266dba4da131f872 /tests/libtcc_test.c | |
| parent | 3db219477a6365d0f1d5214a345b3393a38e81d1 (diff) | |
| download | tinycc-8bbde91f62291cb0383c2406ae6123be903c944b.tar.gz tinycc-8bbde91f62291cb0383c2406ae6123be903c944b.tar.bz2 | |
tcc_relocate: revert to 0.9.24 behavior
Diffstat (limited to 'tests/libtcc_test.c')
| -rw-r--r-- | tests/libtcc_test.c | 18 |
1 files changed, 5 insertions, 13 deletions
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; } |
