summaryrefslogtreecommitdiffstats
path: root/xml/src
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2009-09-09 18:15:23 -0700
committerElliott Hughes <enh@google.com>2009-09-10 10:28:12 -0700
commit80e88aa4b239511ea5cdedc7183d05bcbaba908e (patch)
treea57d2734424c79302644f4bf0ce3da166ccfeefd /xml/src
parent91e2974c5b1f3b938a4f1f1c57447d01973ad0ba (diff)
downloadlibcore-80e88aa4b239511ea5cdedc7183d05bcbaba908e.zip
libcore-80e88aa4b239511ea5cdedc7183d05bcbaba908e.tar.gz
libcore-80e88aa4b239511ea5cdedc7183d05bcbaba908e.tar.bz2
Use GetStringRegion/GetStringUTFRegion where appropriate.
Note that the changes to DecimalFormatInterface.cpp and RBNFInterface.cpp are just minor tidy-ups, fixing an issue where the early error exit wouldn't call ReleaseStringChars to undo the earlier call to GetStringChars. Also remove a dead function and fix a comment in ExpatParser.cpp. Tested on sapphire-eng. Bug: 1639287
Diffstat (limited to 'xml/src')
-rw-r--r--xml/src/main/native/org_apache_harmony_xml_ExpatParser.cpp26
1 files changed, 6 insertions, 20 deletions
diff --git a/xml/src/main/native/org_apache_harmony_xml_ExpatParser.cpp b/xml/src/main/native/org_apache_harmony_xml_ExpatParser.cpp
index 40a4116..6132107 100644
--- a/xml/src/main/native/org_apache_harmony_xml_ExpatParser.cpp
+++ b/xml/src/main/native/org_apache_harmony_xml_ExpatParser.cpp
@@ -105,16 +105,7 @@ static jclass stringClass;
static jstring emptyString;
/**
- * Throws a NullPointerException.
- *
- * @param msg exception message
- */
-static void throw_NullPointerException(JNIEnv* env, const char* msg) {
- jniThrowException(env, "java/lang/NullPointerException", msg);
-}
-
-/**
- * Throw a NullPointerException.
+ * Throws OutOfMemoryError.
*/
static void throw_OutOfMemoryError(JNIEnv* env) {
jniThrowException(env, "java/lang/OutOfMemoryError", "Out of memory.");
@@ -1308,26 +1299,21 @@ static jint getAttributeIndex(JNIEnv* env, jobject clazz,
return getAttributeIndexForQName(
env, clazz, attributePointer, localName);
}
-
int localNameLength = env->GetStringUTFLength(localName);
// Create string in the same format used by Expat: "uri|localName"
+ // TODO: do we have a guarantee that uriLength and localNameLength are small?
char concatenated[uriLength + localNameLength + 2];
// Append uri.
- const char* uriBytes = env->GetStringUTFChars(uri, NULL);
- if (uriBytes == NULL) return -1;
- strcpy(concatenated, uriBytes);
- env->ReleaseStringUTFChars(uri, uriBytes);
+ env->GetStringUTFRegion(uri, 0, uriLength, concatenated);
- // Separarator.
+ // Separator.
concatenated[uriLength] = '|';
// Append local name.
- const char* localNameBytes = env->GetStringUTFChars(localName, NULL);
- if (localNameBytes == NULL) return -1;
- strcpy(concatenated + uriLength + 1, localNameBytes);
- env->ReleaseStringUTFChars(localName, localNameBytes);
+ env->GetStringUTFRegion(localName, 0, localNameLength,
+ concatenated + uriLength + 1);
return findAttributeByName(attributes, concatenated);
}