You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2014/02/10 14:06:58 UTC

svn commit: r1566606 - /subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_base.cpp

Author: brane
Date: Mon Feb 10 13:06:58 2014
New Revision: 1566606

URL: http://svn.apache.org/r1566606
Log:
Follow up to r1566578: Fix a couple thinkos and typos in JavaHL
message localization.

* subversion/bindings/javahl/native/jniwrapper/jni_base.cpp: Include <memory>.
  (make_typed_error): Renamed from error_printf, declared nothrow(),
   and uses the non-throwing memory allocator. Updated all callers.
  (Java::Env::error_get_contents_array,
   Java::Env::error_release_null_array): Properly define as Env methods.
  (Java::Env::error_release_null_string,
  Java::Env::error_release_null_array): Change error message wording
   to match the other messages from Java::Env.

Modified:
    subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_base.cpp

Modified: subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_base.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_base.cpp?rev=1566606&r1=1566605&r2=1566606&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_base.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_base.cpp Mon Feb 10 13:06:58 2014
@@ -22,6 +22,7 @@
  */
 
 #include <cstring>
+#include <memory>
 #include <apr.h>
 
 #include "jni_env.hpp"
@@ -107,7 +108,7 @@ const char* Env::error_get_contents_stri
 
 const char* Env::error_release_null_string() throw()
 {
-  return _("Can not release contents of a null String");
+  return _("Could not release contents of a null String");
 }
 
 const char* Env::error_create_object_array() throw()
@@ -116,13 +117,13 @@ const char* Env::error_create_object_arr
 }
 
 namespace {
-// The typed array error messages are always fatal, so allocating the
-// error messages on the heap does not really constitute a memory
-// leak.
-const char* error_printf(const char* fmt, const char* type)
+// The typed array error messages are always fatal, so allocating
+// the buffer on the heap and never releasing it does not really
+// constitute a memory leak.
+const char* make_typed_error(const char* fmt, const char* type) throw()
 {
   const apr_size_t bufsize = 512;
-  char *msg = new char[bufsize];
+  char *msg = new(std::nothrow) char[bufsize];
   apr_snprintf(msg, bufsize, fmt, type);
   return msg;
 }
@@ -130,17 +131,18 @@ const char* error_printf(const char* fmt
 
 const char* Env::error_create_array(const char* type) throw()
 {
-  return error_printf(_("Could not create %sArray"), type);
+  return make_typed_error(_("Could not create %sArray"), type);
 }
 
-const char* error_get_contents_array(const char* type) throw()
+const char* Env::error_get_contents_array(const char* type) throw()
 {
-  return error_printf(_("Could not get %s array contents"), type);
+  return make_typed_error(_("Could not get %s array contents"), type);
 }
 
-const char* error_release_null_array(const char* type) throw()
+const char* Env::error_release_null_array(const char* type) throw()
 {
-  return error_printf(_("Can not release contents of a null %sArray"), type);
+  return make_typed_error(
+      _("Could not release contents of a null %sArray"), type);
 }
 
 ::JNIEnv* Env::env_from_jvm()