summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Varga <nite@hq.sk>2016-02-01 18:12:18 +0100
committerRobert Varga <nite@hq.sk>2016-02-01 18:42:53 +0100
commit427ce225831af2959349c5e0332019433e8bf95f (patch)
tree7e3c4dd2d233a3774954af622e0aade0b0dafe2e
parent74574228b0f63a3c8fd373321ed25f4d24308df0 (diff)
Do not copy data twice in swInterfaceDump()
Instead of performing getting the elements, memcpy()ing them and the releasing, use GetByteArrayRegion(). Change-Id: I20ef181df214ac4fdcaff5a64b89ef4f879078f8 Signed-off-by: Robert Varga <nite@hq.sk>
-rw-r--r--vpp-japi/japi/vppjni.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/vpp-japi/japi/vppjni.c b/vpp-japi/japi/vppjni.c
index b874af892ed..f7047bb0c81 100644
--- a/vpp-japi/japi/vppjni.c
+++ b/vpp-japi/japi/vppjni.c
@@ -624,8 +624,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_swInterfaceDump
vppjni_lock (jm, 7);
my_context_id = vppjni_get_context_id (jm);
- jbyte * name_filterP = (*env)->GetByteArrayElements (env, name_filter, NULL);
- int cnt = (*env)->GetArrayLength (env, name_filter);
+ jsize cnt = (*env)->GetArrayLength (env, name_filter);
M(SW_INTERFACE_DUMP, sw_interface_dump);
mp->context = clib_host_to_net_u32 (my_context_id);
@@ -634,8 +633,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_swInterfaceDump
if (cnt > sizeof(mp->name_filter))
cnt = sizeof(mp->name_filter);
- memcpy ((char *) mp->name_filter, name_filterP, cnt);
- (*env)->ReleaseByteArrayElements (env, name_filter, name_filterP, 0);
+ (*env)->GetByteArrayRegion(env, name_filter, 0, cnt, (jbyte *)mp->name_filter);
DEBUG_LOG ("interface filter (%d, %s, len: %d)", mp->name_filter_valid, (char *)mp->name_filter, cnt);