* [RFA/JVMTI] _Jv_Malloc cleanup
@ 2006-09-20 23:58 Keith Seitz
2006-09-21 0:02 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Keith Seitz @ 2006-09-20 23:58 UTC (permalink / raw)
To: Java Patch List
[-- Attachment #1: Type: text/plain, Size: 621 bytes --]
Hi,
Earlier Tom mentioned something about the _Jv_Malloc mess in jvmti.cc.
This patch changes all the calls to _Jv_Malloc to use
_Jv_MallocUnchecked and returns JVMTI_ERROR_OUT_OF_MEMORY when the
malloc fails.
Okay?
Keith
ChangeLog
2006-09-20 Keith Seitz <keiths@redhat.com>
* jvmti.cc (_Jv_JVMTI_CreateRawMonitor): Use _Jv_MallocUnchked
and return JVMTI_ERROR_OUT_OF_MEMORY if necessary.
(_Jv_JVMTI_GetClassMethods): Likewise.
(_Jv_JVMTI_GetClassLoaderClasses): Likewise.
(_Jv_JVMTI_GetJNIFunctionTable): Likewise.
(_Jv_JVMTI_GetSystemProperty): Likewise.
[-- Attachment #2: jvmti-mallocunchecked.patch --]
[-- Type: text/x-patch, Size: 2311 bytes --]
Index: jvmti.cc
===================================================================
--- jvmti.cc (revision 117093)
+++ jvmti.cc (working copy)
@@ -156,7 +156,9 @@
REQUIRE_PHASE (env, JVMTI_PHASE_ONLOAD | JVMTI_PHASE_LIVE);
NULL_CHECK (name);
NULL_CHECK (result);
- *result = (jrawMonitorID) _Jv_Malloc (sizeof (_Jv_rawMonitorID));
+ *result = (jrawMonitorID) _Jv_MallocUnchecked (sizeof (_Jv_rawMonitorID));
+ if (*result == NULL)
+ return JVMTI_ERROR_OUT_OF_MEMORY;
_Jv_MutexInit (&(*result)->mutex);
_Jv_CondInit (&(*result)->condition);
return JVMTI_ERROR_NONE;
@@ -285,7 +287,11 @@
NULL_CHECK (methods_ptr);
*count_ptr = JvNumMethods(klass);
- *methods_ptr = (jmethodID *) _Jv_Malloc (*count_ptr * sizeof (jmethodID));
+ *methods_ptr
+ = (jmethodID *) _Jv_MallocUnchecked (*count_ptr * sizeof (jmethodID));
+ if (*methods_ptr == NULL)
+ return JVMTI_ERROR_OUT_OF_MEMORY;
+
jmethodID start = JvGetFirstMethod (klass);
for (jint i = 0; i < *count_ptr; ++i)
// FIXME: correct?
@@ -437,7 +443,11 @@
jobjectArray array = values->toArray();
*count_ptr = array->length;
jobject *elts = elements (array);
- jclass *result = (jclass *) _Jv_Malloc (*count_ptr * sizeof (jclass));
+ jclass *result
+ = (jclass *) _Jv_MallocUnchecked (*count_ptr * sizeof (jclass));
+ if (result == NULL)
+ return JVMTI_ERROR_OUT_OF_MEMORY;
+
// FIXME: JNI references...
memcpy (result, elts, *count_ptr * sizeof (jclass));
@@ -471,7 +481,9 @@
REQUIRE_PHASE (env, JVMTI_PHASE_START | JVMTI_PHASE_LIVE);
NULL_CHECK (function_table);
*function_table
- = (jniNativeInterface *) _Jv_Malloc (sizeof (jniNativeInterface));
+ = (jniNativeInterface *) _Jv_MallocUnchecked (sizeof (jniNativeInterface));
+ if (*function_table == NULL)
+ return JVMTI_ERROR_OUT_OF_MEMORY;
memcpy (*function_table, &_Jv_JNIFunctions, sizeof (jniNativeInterface));
return JVMTI_ERROR_NONE;
}
@@ -525,7 +537,9 @@
return JVMTI_ERROR_NOT_AVAILABLE;
int len = JvGetStringUTFLength (result_str);
- *result = (char *) _Jv_Malloc (len + 1);
+ *result = (char *) _Jv_MallocUnchecked (len + 1);
+ if (*result == NULL)
+ return JVMTI_ERROR_OUT_OF_MEMORY;
JvGetStringUTFRegion (result_str, 0, result_str->length(), *result);
(*result)[len] = '\0';
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA/JVMTI] _Jv_Malloc cleanup
2006-09-20 23:58 [RFA/JVMTI] _Jv_Malloc cleanup Keith Seitz
@ 2006-09-21 0:02 ` Tom Tromey
2006-09-21 0:16 ` Keith Seitz
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2006-09-21 0:02 UTC (permalink / raw)
To: Keith Seitz; +Cc: Java Patch List
>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:
Keith> Earlier Tom mentioned something about the _Jv_Malloc mess in
Keith> jvmti.cc. This patch changes all the calls to _Jv_Malloc to use
Keith> _Jv_MallocUnchecked and returns JVMTI_ERROR_OUT_OF_MEMORY when the
Keith> malloc fails.
Keith> Okay?
Yes, thanks.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA/JVMTI] _Jv_Malloc cleanup
2006-09-21 0:02 ` Tom Tromey
@ 2006-09-21 0:16 ` Keith Seitz
0 siblings, 0 replies; 3+ messages in thread
From: Keith Seitz @ 2006-09-21 0:16 UTC (permalink / raw)
To: Java Patch List
Tom Tromey wrote:
>>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:
> Keith> Okay?
>
> Yes, thanks.
Done. Thank you.
Keith
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-09-21 0:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-20 23:58 [RFA/JVMTI] _Jv_Malloc cleanup Keith Seitz
2006-09-21 0:02 ` Tom Tromey
2006-09-21 0:16 ` Keith Seitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).