From 4b77f0f1f44be6064a6c725c435880d827db53a2 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 26 Mar 2008 16:46:44 +0000 Subject: [PATCH] use jsigar_list --- bindings/java/src/jni/win32/service.cpp | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/bindings/java/src/jni/win32/service.cpp b/bindings/java/src/jni/win32/service.cpp index df2daf38..304b5721 100644 --- a/bindings/java/src/jni/win32/service.cpp +++ b/bindings/java/src/jni/win32/service.cpp @@ -223,15 +223,8 @@ JNIEXPORT jobject SIGAR_JNI(win32_Service_getServiceNames) { DWORD i, status; sigar_services_status_t ss; - jobject listobj; - jclass listclass = - env->FindClass("java/util/ArrayList"); - jmethodID listid = - env->GetMethodID(listclass, "", "()V"); - jmethodID addid = - env->GetMethodID(listclass, "add", - "(Ljava/lang/Object;)" - "Z"); + jsigar_list_t obj; + SIGAR_ZERO(&ss); status = sigar_services_status_get(&ss, SERVICE_STATE_ALL); if (status != SIGAR_OK) { @@ -239,17 +232,15 @@ JNIEXPORT jobject SIGAR_JNI(win32_Service_getServiceNames) return NULL; } - listobj = env->NewObject(listclass, listid); - for (i=0; iNewStringUTF((char *)ss.services[i].lpServiceName); + jsigar_list_init(env, &obj); - env->CallBooleanMethod(listobj, addid, name); + for (i=0; i