Avoid memory leak.

pull/25328/head
yang-g 4 years ago
parent 9b749bfe0f
commit cf85e6abe6
  1. 24
      src/android/test/interop/app/src/main/cpp/grpc-interop.cc

@ -51,7 +51,9 @@ Java_io_grpc_interop_cpp_InteropActivity_doEmpty(JNIEnv* env, jobject obj_this,
int port = static_cast<int>(port_raw);
bool use_tls = static_cast<bool>(use_tls_raw);
return GetClient(host, port, use_tls)->DoEmpty();
jboolean result = GetClient(host, port, use_tls)->DoEmpty();
env->ReleaseStringUTFChars(host_raw, host);
return result;
}
extern "C" JNIEXPORT jboolean JNICALL
@ -64,7 +66,9 @@ Java_io_grpc_interop_cpp_InteropActivity_doLargeUnary(JNIEnv* env,
int port = static_cast<int>(port_raw);
bool use_tls = static_cast<bool>(use_tls_raw);
return GetClient(host, port, use_tls)->DoLargeUnary();
jboolean result = GetClient(host, port, use_tls)->DoLargeUnary();
env->ReleaseStringUTFChars(host_raw, host);
return result;
}
extern "C" JNIEXPORT jboolean JNICALL
@ -77,7 +81,9 @@ Java_io_grpc_interop_cpp_InteropActivity_doEmptyStream(JNIEnv* env,
int port = static_cast<int>(port_raw);
bool use_tls = static_cast<bool>(use_tls_raw);
return GetClient(host, port, use_tls)->DoEmptyStream();
jboolean result = GetClient(host, port, use_tls)->DoEmptyStream();
env->ReleaseStringUTFChars(host_raw, host);
return result;
}
extern "C" JNIEXPORT jboolean JNICALL
@ -88,7 +94,9 @@ Java_io_grpc_interop_cpp_InteropActivity_doRequestStreaming(
int port = static_cast<int>(port_raw);
bool use_tls = static_cast<bool>(use_tls_raw);
return GetClient(host, port, use_tls)->DoRequestStreaming();
jboolean result = GetClient(host, port, use_tls)->DoRequestStreaming();
env->ReleaseStringUTFChars(host_raw, host);
return result;
}
extern "C" JNIEXPORT jboolean JNICALL
@ -99,7 +107,9 @@ Java_io_grpc_interop_cpp_InteropActivity_doResponseStreaming(
int port = static_cast<int>(port_raw);
bool use_tls = static_cast<bool>(use_tls_raw);
return GetClient(host, port, use_tls)->DoResponseStreaming();
jboolean result = GetClient(host, port, use_tls)->DoResponseStreaming();
env->ReleaseStringUTFChars(host_raw, host);
return result;
}
extern "C" JNIEXPORT jboolean JNICALL
@ -112,5 +122,7 @@ Java_io_grpc_interop_cpp_InteropActivity_doPingPong(JNIEnv* env,
int port = static_cast<int>(port_raw);
bool use_tls = static_cast<bool>(use_tls_raw);
return GetClient(host, port, use_tls)->DoPingPong();
jboolean result = GetClient(host, port, use_tls)->DoPingPong();
env->ReleaseStringUTFChars(host_raw, host);
return result;
}

Loading…
Cancel
Save