From 2d2906da813362d83bc6a7d7093eefcc9566dbb1 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 12 Apr 2018 15:08:22 +0200 Subject: loplugin:useuniqueptr in bridges Change-Id: I7bf75ffafa63ec88e89192ed32880675c9ae1d61 Reviewed-on: https://gerrit.libreoffice.org/52883 Tested-by: Jenkins Reviewed-by: Noel Grandin --- bridges/source/jni_uno/jni_info.cxx | 14 +++++++------- bridges/source/jni_uno/jni_info.h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bridges/source/jni_uno/jni_info.cxx b/bridges/source/jni_uno/jni_info.cxx index 82b773d6d58c..9b43356856af 100644 --- a/bridges/source/jni_uno/jni_info.cxx +++ b/bridges/source/jni_uno/jni_info.cxx @@ -61,7 +61,7 @@ void JNI_interface_type_info::destroy( JNIEnv * jni_env ) JNI_type_info::destruct( jni_env ); jni_env->DeleteGlobalRef( m_proxy_ctor ); jni_env->DeleteGlobalRef( m_type ); - delete [] m_methods; + m_methods.reset(); delete this; } @@ -104,7 +104,7 @@ JNI_interface_type_info::JNI_interface_type_info( reinterpret_cast< typelib_InterfaceTypeDescription * >( m_td.get() ); // coverity [ctor_dtor_leak] - m_methods = new jmethodID[ td->nMapFunctionIndexToMemberIndex ]; + m_methods.reset(new jmethodID[ td->nMapFunctionIndexToMemberIndex ]); sal_Int32 nMethodIndex = 0; typelib_TypeDescriptionReference ** ppMembers = td->ppMembers; sal_Int32 nMembers = td->nMembers; @@ -211,7 +211,7 @@ JNI_interface_type_info::JNI_interface_type_info( } catch (...) { - delete [] m_methods; + m_methods.reset(); throw; } } @@ -224,7 +224,7 @@ JNI_interface_type_info::JNI_interface_type_info( void JNI_compound_type_info::destroy( JNIEnv * jni_env ) { JNI_type_info::destruct( jni_env ); - delete [] m_fields; + m_fields.reset(); delete this; } @@ -289,7 +289,7 @@ JNI_compound_type_info::JNI_compound_type_info( jni_info->m_RuntimeException_type.getTypeLibType() )) { // coverity [ctor_dtor_leak] - m_fields = new jfieldID[ 2 ]; + m_fields.reset(new jfieldID[ 2 ]); m_fields[ 0 ] = nullptr; // special Throwable.getMessage() // field Context m_fields[ 1 ] = jni->GetFieldID( @@ -301,7 +301,7 @@ JNI_compound_type_info::JNI_compound_type_info( { // retrieve field ids for all direct members sal_Int32 nMembers = td->nMembers; - m_fields = new jfieldID[ nMembers ]; + m_fields.reset(new jfieldID[ nMembers ]); for ( sal_Int32 nPos = 0; nPos < nMembers; ++nPos ) { @@ -334,7 +334,7 @@ JNI_compound_type_info::JNI_compound_type_info( } catch (...) { - delete [] m_fields; + m_fields.reset(); throw; } diff --git a/bridges/source/jni_uno/jni_info.h b/bridges/source/jni_uno/jni_info.h index 920e78453afe..98ba7c9e505a 100644 --- a/bridges/source/jni_uno/jni_info.h +++ b/bridges/source/jni_uno/jni_info.h @@ -82,7 +82,7 @@ struct JNI_interface_type_info : public JNI_type_info jobject m_proxy_ctor; // proxy ctor jobject m_type; // sorted via typelib function index - jmethodID * m_methods; + std::unique_ptr m_methods; virtual void destroy( JNIEnv * jni_env ) override; explicit JNI_interface_type_info( @@ -98,7 +98,7 @@ struct JNI_compound_type_info : public JNI_type_info // ctor( msg ) for exceptions jmethodID m_exc_ctor; // sorted via typelib member index - jfieldID * m_fields; + std::unique_ptr m_fields; virtual void destroy( JNIEnv * jni_env ) override; explicit JNI_compound_type_info( -- cgit