Author: mturk Date: Thu Aug 6 20:02:26 2009 New Revision: 801800 URL: http://svn.apache.org/viewvc?rev=801800&view=rev Log: Revert double zero terminating chars
Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_string.h commons/sandbox/runtime/trunk/src/main/native/shared/string.c Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_string.h URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_string.h?rev=801800&r1=801799&r2=801800&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/include/acr_string.h (original) +++ commons/sandbox/runtime/trunk/src/main/native/include/acr_string.h Thu Aug 6 20:02:26 2009 @@ -144,8 +144,7 @@ /** * Apache's "replacement" for the strdup() function that throws - * the java.lang.OutOfMemoryError in case of failure and has double - * zero temination. + * the java.lang.OutOfMemoryError in case of failure. * @param env Current JNI environment. * @param file Source file where the function was called * @param line Source file line where the function was called @@ -157,8 +156,7 @@ /** * Apache's "replacement" for the wcsdup() function that throws - * the java.lang.OutOfMemoryError in case of failure and has double - * zero temination. + * the java.lang.OutOfMemoryError in case of failure. * @param env Current JNI environment. * @param file Source file where the function was called * @param line Source file line where the function was called Modified: commons/sandbox/runtime/trunk/src/main/native/shared/string.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/string.c?rev=801800&r1=801799&r2=801800&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/shared/string.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/shared/string.c Thu Aug 6 20:02:26 2009 @@ -580,7 +580,7 @@ char *d = NULL; if (s) { size_t size = strlen(s); - d = malloc(size + 2); + d = malloc(size + 1); if (!d) { int err = ACR_GET_OS_ERROR(); if (_E == NULL) @@ -589,7 +589,6 @@ ACR_ThrowException(_E, file, line, ACR_EX_ENOMEM, err); } memcpy(d, s, size); - d[size++] = '\0'; d[size] = '\0'; } return d; @@ -601,7 +600,7 @@ wchar_t *d = NULL; if (s) { size_t size = wcslen(s); - d = malloc((size + 2) * sizeof(wchar_t)); + d = malloc((size + 1) * sizeof(wchar_t)); if (!d) { int err = ACR_GET_OS_ERROR(); if (_E == NULL) @@ -610,7 +609,6 @@ ACR_ThrowException(_E, file, line, ACR_EX_ENOMEM, err); } memcpy(d, s, size * sizeof(wchar_t)); - d[size++] = L'\0'; d[size] = L'\0'; } return d;