summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--platform/android/src/conversion/collection.hpp1
-rw-r--r--platform/android/src/file_source.cpp5
-rw-r--r--platform/android/src/map/camera_position.cpp4
-rw-r--r--platform/android/src/map/image.cpp4
4 files changed, 11 insertions, 3 deletions
diff --git a/platform/android/src/conversion/collection.hpp b/platform/android/src/conversion/collection.hpp
index 549121c7ef..2b953e73f4 100644
--- a/platform/android/src/conversion/collection.hpp
+++ b/platform/android/src/conversion/collection.hpp
@@ -28,6 +28,7 @@ inline jni::jobject* toArrayList(JNIEnv& env, jni::jarray<T>& array) {
inline std::vector<std::string> toVector(JNIEnv& env, jni::jarray<jni::jobject>& array) {
std::vector<std::string> vector;
std::size_t len = jni::GetArrayLength(env, array);
+ vector.reserve(len);
for (std::size_t i = 0; i < len; i++) {
jni::jstring* jstr = reinterpret_cast<jni::jstring*>(jni::GetObjectArrayElement(env, array, i));
diff --git a/platform/android/src/file_source.cpp b/platform/android/src/file_source.cpp
index 6a9d7badb0..612619a30b 100644
--- a/platform/android/src/file_source.cpp
+++ b/platform/android/src/file_source.cpp
@@ -124,8 +124,11 @@ jni::Class<FileSource::ResourceTransformCallback> FileSource::ResourceTransformC
std::string FileSource::ResourceTransformCallback::onURL(jni::JNIEnv& env, jni::Object<FileSource::ResourceTransformCallback> callback, int kind, std::string url_) {
static auto method = FileSource::ResourceTransformCallback::javaClass.GetMethod<jni::String (jni::jint, jni::String)>(env, "onURL");
auto url = jni::Make<jni::String>(env, url_);
+
url = callback.Call(env, method, kind, url);
- return jni::Make<std::string>(env, url);
+ auto urlStr = jni::Make<std::string>(env, url);
+ jni::DeleteLocalRef(env, url);
+ return urlStr;
}
} // namespace android
diff --git a/platform/android/src/map/camera_position.cpp b/platform/android/src/map/camera_position.cpp
index 1fc5f9789f..01ffc6530b 100644
--- a/platform/android/src/map/camera_position.cpp
+++ b/platform/android/src/map/camera_position.cpp
@@ -33,7 +33,9 @@ mbgl::CameraOptions CameraPosition::getCameraOptions(jni::JNIEnv& env, jni::Obje
static auto tilt = CameraPosition::javaClass.GetField<jni::jdouble>(env, "tilt");
static auto zoom = CameraPosition::javaClass.GetField<jni::jdouble>(env, "zoom");
- auto center = LatLng::getLatLng(env, position.Get(env, target));
+ auto jtarget = position.Get(env, target);
+ auto center = LatLng::getLatLng(env, jtarget);
+ jni::DeleteLocalRef(env, jtarget);
return mbgl::CameraOptions {
center,
diff --git a/platform/android/src/map/image.cpp b/platform/android/src/map/image.cpp
index 5f5c90eddd..52e0e0d255 100644
--- a/platform/android/src/map/image.cpp
+++ b/platform/android/src/map/image.cpp
@@ -16,7 +16,9 @@ mbgl::style::Image Image::getImage(jni::JNIEnv& env, jni::Object<Image> image) {
auto width = image.Get(env, widthField);
auto pixelRatio = image.Get(env, pixelRatioField);
auto pixels = image.Get(env, bufferField);
- auto name = jni::Make<std::string>(env, image.Get(env, nameField));
+ auto jName = image.Get(env, nameField);
+ auto name = jni::Make<std::string>(env, jName);
+ jni::DeleteLocalRef(env, jName);
jni::NullCheck(env, &pixels);
std::size_t size = pixels.Length(env);