aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/native/unix_jni.cc
diff options
context:
space:
mode:
authorGravatar Thiago Farina <tfarina@chromium.org>2015-04-01 17:42:29 +0000
committerGravatar Han-Wen Nienhuys <hanwen@google.com>2015-04-01 17:49:48 +0000
commita924c8057ed886fd27b6099eeada366d1823d30b (patch)
tree8f586ccebf9e3ad35ddacbf0914b8e9a4008253b /src/main/native/unix_jni.cc
parente9029d4613d98c17e05236a0058164bb8787f94b (diff)
Use the constant length from Md5Digest API.
-- Change-Id: I97b35fa8d49e31724bddf33ad1f25834bfc67e32 MOS_MIGRATED_REVID=90078101
Diffstat (limited to 'src/main/native/unix_jni.cc')
-rw-r--r--src/main/native/unix_jni.cc17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/main/native/unix_jni.cc b/src/main/native/unix_jni.cc
index 363cd530e8..5e237fd81e 100644
--- a/src/main/native/unix_jni.cc
+++ b/src/main/native/unix_jni.cc
@@ -35,9 +35,7 @@
#include "util/md5.h"
#include "unix_jni.h"
-namespace {
- const int kMd5DigestLength = 16;
-}
+using blaze_util::Md5Digest;
////////////////////////////////////////////////////////////////////////
// Latin1 <--> java.lang.String conversion functions.
@@ -776,10 +774,11 @@ Java_com_google_devtools_build_lib_unix_FilesystemUtils_lgetxattr(JNIEnv *env,
// Computes MD5 digest of "file", writes result in "result", which
-// must be of length kMd5DigestLength. Returns zero on success, or
+// must be of length Md5Digest::kDigestLength. Returns zero on success, or
// -1 (and sets errno) otherwise.
-static int md5sumAsBytes(const char *file, jbyte result[kMd5DigestLength]) {
- blaze_util::Md5Digest digest;
+static int md5sumAsBytes(const char *file,
+ jbyte result[Md5Digest::kDigestLength]) {
+ Md5Digest digest;
// OPT: Using a 32k buffer would give marginally better performance,
// but what is the stack size here?
jbyte buf[4096];
@@ -815,11 +814,11 @@ extern "C" JNIEXPORT jbyteArray JNICALL
Java_com_google_devtools_build_lib_unix_FilesystemUtils_md5sumAsBytes(
JNIEnv *env, jclass clazz, jstring path) {
const char *path_chars = GetStringLatin1Chars(env, path);
- jbyte value[kMd5DigestLength];
+ jbyte value[Md5Digest::kDigestLength];
jbyteArray result = NULL;
if (md5sumAsBytes(path_chars, value) == 0) {
- result = env->NewByteArray(kMd5DigestLength);
- env->SetByteArrayRegion(result, 0, kMd5DigestLength, value);
+ result = env->NewByteArray(Md5Digest::kDigestLength);
+ env->SetByteArrayRegion(result, 0, Md5Digest::kDigestLength, value);
} else {
::PostFileException(env, errno, path_chars);
}