aboutsummaryrefslogtreecommitdiff
path: root/tests/libtcc_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/libtcc_test.c')
-rw-r--r--tests/libtcc_test.c18
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;
}