diff options
author | 2017-07-05 10:34:49 -0700 | |
---|---|---|
committer | 2017-07-05 10:49:16 -0700 | |
commit | bf64a57227b8001adc4840ccda9c3f4122ff9ac5 (patch) | |
tree | 757e968da8a4d7d56b6900c5d7143a895794e637 /runtime/openjdkjvmti/OpenjdkJvmTi.cc | |
parent | fe9a4f061841a3c597aac6817a47c799c54fcad7 (diff) |
Move jvmti allocation functions to own file.
This matches the style of most other jvmti functions and makes it
simpler to extend and tweak these functions later.
Bug: 62065509
Test: ./test.py --host -j40
Change-Id: I7080bf0fc211faaa0e481f6d401172fbdf6d36d6
Diffstat (limited to 'runtime/openjdkjvmti/OpenjdkJvmTi.cc')
-rw-r--r-- | runtime/openjdkjvmti/OpenjdkJvmTi.cc | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/runtime/openjdkjvmti/OpenjdkJvmTi.cc b/runtime/openjdkjvmti/OpenjdkJvmTi.cc index e3768b358f..21239fe3de 100644 --- a/runtime/openjdkjvmti/OpenjdkJvmTi.cc +++ b/runtime/openjdkjvmti/OpenjdkJvmTi.cc @@ -48,6 +48,7 @@ #include "scoped_thread_state_change-inl.h" #include "thread-current-inl.h" #include "thread_list.h" +#include "ti_allocator.h" #include "ti_breakpoint.h" #include "ti_class.h" #include "ti_dump.h" @@ -109,22 +110,12 @@ class JvmtiFunctions { static jvmtiError Allocate(jvmtiEnv* env, jlong size, unsigned char** mem_ptr) { ENSURE_VALID_ENV(env); ENSURE_NON_NULL(mem_ptr); - if (size < 0) { - return ERR(ILLEGAL_ARGUMENT); - } else if (size == 0) { - *mem_ptr = nullptr; - return OK; - } - *mem_ptr = static_cast<unsigned char*>(malloc(size)); - return (*mem_ptr != nullptr) ? OK : ERR(OUT_OF_MEMORY); + return AllocUtil::Allocate(env, size, mem_ptr); } static jvmtiError Deallocate(jvmtiEnv* env, unsigned char* mem) { ENSURE_VALID_ENV(env); - if (mem != nullptr) { - free(mem); - } - return OK; + return AllocUtil::Deallocate(env, mem); } static jvmtiError GetThreadState(jvmtiEnv* env, jthread thread, jint* thread_state_ptr) { |