diff options
author | Narayan Kamath <narayan@google.com> | 2014-01-27 11:17:22 +0000 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2014-01-27 11:20:24 +0000 |
commit | 745d4efc8369d255341d810790132660e33d3b61 (patch) | |
tree | f28ae30721d932409fd8189ac6ef5c0289d106c2 /core/jni/android_util_AssetManager.cpp | |
parent | 9fc157a4767f54d1cff53dc9489638b67aec2da3 (diff) | |
download | frameworks_base-745d4efc8369d255341d810790132660e33d3b61.zip frameworks_base-745d4efc8369d255341d810790132660e33d3b61.tar.gz frameworks_base-745d4efc8369d255341d810790132660e33d3b61.tar.bz2 |
AssetManager cookies should be int32_t and not void*.
Cookies are really indices into vectors and arrays, so
they don't need to be void*. We choose int32_t instead
of size_t to allow their width to be well specified.
(cherry picked from commit ebfdd0f467e39c3af8d92cade78263935340acb7)
(cherry picked from commit a7fa2e592e2e579e5acdb903dba83fc074ebc215)
(cherry picked from commit a9d5701b034ed2d9771b3f0943e1add00741d7cd)
Change-Id: I2aed3db568b6fdc487bf99e2c5dd123206736fda
Diffstat (limited to 'core/jni/android_util_AssetManager.cpp')
-rw-r--r-- | core/jni/android_util_AssetManager.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp index 2c23f9d..8836918 100644 --- a/core/jni/android_util_AssetManager.cpp +++ b/core/jni/android_util_AssetManager.cpp @@ -229,7 +229,8 @@ static jint android_content_AssetManager_openNonAssetNative(JNIEnv* env, jobject } Asset* a = cookie - ? am->openNonAsset((void*)cookie, fileName8.c_str(), (Asset::AccessMode)mode) + ? am->openNonAsset(static_cast<int32_t>(cookie), fileName8.c_str(), + (Asset::AccessMode)mode) : am->openNonAsset(fileName8.c_str(), (Asset::AccessMode)mode); if (a == NULL) { @@ -260,7 +261,7 @@ static jobject android_content_AssetManager_openNonAssetFdNative(JNIEnv* env, jo } Asset* a = cookie - ? am->openNonAsset((void*)cookie, fileName8.c_str(), Asset::ACCESS_RANDOM) + ? am->openNonAsset(static_cast<int32_t>(cookie), fileName8.c_str(), Asset::ACCESS_RANDOM) : am->openNonAsset(fileName8.c_str(), Asset::ACCESS_RANDOM); if (a == NULL) { @@ -435,10 +436,10 @@ static jint android_content_AssetManager_addAssetPath(JNIEnv* env, jobject clazz return 0; } - void* cookie; + int32_t cookie; bool res = am->addAssetPath(String8(path8.c_str()), &cookie); - return (res) ? (jint)cookie : 0; + return (res) ? static_cast<jint>(cookie) : 0; } static jboolean android_content_AssetManager_isUpToDate(JNIEnv* env, jobject clazz) @@ -800,7 +801,7 @@ static jstring android_content_AssetManager_getCookieName(JNIEnv* env, jobject c if (am == NULL) { return NULL; } - String8 name(am->getAssetPath((void*)cookie)); + String8 name(am->getAssetPath(static_cast<int32_t>(cookie))); if (name.length() == 0) { jniThrowException(env, "java/lang/IndexOutOfBoundsException", "Empty cookie name"); return NULL; @@ -1386,7 +1387,7 @@ static jint android_content_AssetManager_openXmlAssetNative(JNIEnv* env, jobject } Asset* a = cookie - ? am->openNonAsset((void*)cookie, fileName8.c_str(), Asset::ACCESS_BUFFER) + ? am->openNonAsset(static_cast<int32_t>(cookie), fileName8.c_str(), Asset::ACCESS_BUFFER) : am->openNonAsset(fileName8.c_str(), Asset::ACCESS_BUFFER); if (a == NULL) { |