From 8adc8afc6395e50f33203dc9f7de18a64016712f Mon Sep 17 00:00:00 2001 From: Chris Eagle Date: Tue, 10 Jan 2017 17:27:16 -0800 Subject: [PATCH] Java bindings (#711) * Remove glib from samples makefile * support new APIs * reimplement register batch mode interface * stop using deprecated java API --- bindings/java/unicorn/Unicorn.java | 7 ++++--- bindings/java/unicorn_Unicorn.c | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bindings/java/unicorn/Unicorn.java b/bindings/java/unicorn/Unicorn.java index c649cdd5..279fdbbf 100644 --- a/bindings/java/unicorn/Unicorn.java +++ b/bindings/java/unicorn/Unicorn.java @@ -796,11 +796,12 @@ public class Unicorn implements UnicornConst, ArmConst, Arm64Const, M68kConst, S public native long context_alloc(); /** - * Free the resource allocated by context_alloc. + * Free a resource allocated within Unicorn. Use for handles + * allocated by context_alloc. * - * @param context handle previously returned by context_alloc. + * @param Previously allocated Unicorn object handle. */ - public native void context_free(long context); + public native void free(long handle); /** * Save a copy of the internal CPU context. diff --git a/bindings/java/unicorn_Unicorn.c b/bindings/java/unicorn_Unicorn.c index 6a5b62ee..18af09f8 100644 --- a/bindings/java/unicorn_Unicorn.c +++ b/bindings/java/unicorn_Unicorn.c @@ -718,7 +718,7 @@ JNIEXPORT jobjectArray JNICALL Java_unicorn_Unicorn_mem_1regions jobject mr = (*env)->NewObject(env, clz, cons, regions[i].begin, regions[i].end, regions[i].perms); (*env)->SetObjectArrayElement(env, result, (jsize)i, mr); } - free(regions); + uc_free(regions); return result; } @@ -741,10 +741,10 @@ JNIEXPORT jlong JNICALL Java_unicorn_Unicorn_context_1alloc /* * Class: unicorn_Unicorn - * Method: context_free + * Method: free * Signature: (J)V */ -JNIEXPORT void JNICALL Java_unicorn_Unicorn_context_1free +JNIEXPORT void JNICALL Java_unicorn_Unicorn_free (JNIEnv *env, jobject self, jlong ctx) { uc_err err = uc_free((void *)ctx); if (err != UC_ERR_OK) {