mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 01:45:06 +00:00
[vm] Document ownership of Dart_CreateIsolate's error message.
Change-Id: Icab6f6d169445f66b6ba9469511164e6e21ef49a Reviewed-on: https://dart-review.googlesource.com/18425 Reviewed-by: Zach Anderson <zra@google.com>
This commit is contained in:
parent
c53c2f948d
commit
8753545178
|
@ -835,10 +835,11 @@ DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name);
|
|||
* \param callback_data Embedder data. This data will be passed to
|
||||
* the Dart_IsolateCreateCallback when new isolates are spawned from
|
||||
* this parent isolate.
|
||||
* \param error DOCUMENT
|
||||
* \param error Returns NULL if creation is successful, an error message
|
||||
* otherwise. The caller is responsible for calling free() on the error
|
||||
* message.
|
||||
*
|
||||
* \return The new isolate is returned. May be NULL if an error
|
||||
* occurs during isolate initialization.
|
||||
* \return The new isolate on success, or NULL if isolate creation failed.
|
||||
*/
|
||||
DART_EXPORT Dart_Isolate
|
||||
Dart_CreateIsolate(const char* script_uri,
|
||||
|
@ -869,10 +870,11 @@ Dart_CreateIsolate(const char* script_uri,
|
|||
* \param callback_data Embedder data. This data will be passed to
|
||||
* the Dart_IsolateCreateCallback when new isolates are spawned from
|
||||
* this parent isolate.
|
||||
* \param error DOCUMENT
|
||||
* \param error Returns NULL if creation is successful, an error message
|
||||
* otherwise. The caller is responsible for calling free() on the error
|
||||
* message.
|
||||
*
|
||||
* \return The new isolate is returned. May be NULL if an error
|
||||
* occurs during isolate initialization.
|
||||
* \return The new isolate on success, or NULL if isolate creation failed.
|
||||
*/
|
||||
DART_EXPORT Dart_Isolate Dart_CreateIsolateFromKernel(const char* script_uri,
|
||||
const char* main,
|
||||
|
|
|
@ -1135,7 +1135,9 @@ static Dart_Isolate CreateIsolate(const char* script_uri,
|
|||
Isolate* I = Dart::CreateIsolate(isolate_name, *flags);
|
||||
free(isolate_name);
|
||||
if (I == NULL) {
|
||||
*error = strdup("Isolate creation failed");
|
||||
if (error != NULL) {
|
||||
*error = strdup("Isolate creation failed");
|
||||
}
|
||||
return reinterpret_cast<Dart_Isolate>(NULL);
|
||||
}
|
||||
{
|
||||
|
@ -1164,9 +1166,14 @@ static Dart_Isolate CreateIsolate(const char* script_uri,
|
|||
// outside this scope in Dart_ShutdownIsolate/Dart_ExitIsolate.
|
||||
T->set_execution_state(Thread::kThreadInNative);
|
||||
T->EnterSafepoint();
|
||||
if (error != NULL) {
|
||||
*error = NULL;
|
||||
}
|
||||
return Api::CastIsolate(I);
|
||||
}
|
||||
*error = strdup(error_obj.ToErrorCString());
|
||||
if (error != NULL) {
|
||||
*error = strdup(error_obj.ToErrorCString());
|
||||
}
|
||||
// We exit the API scope entered above.
|
||||
Dart_ExitScope();
|
||||
}
|
||||
|
|
|
@ -14,10 +14,12 @@
|
|||
namespace dart {
|
||||
|
||||
VM_UNIT_TEST_CASE(IsolateCurrent) {
|
||||
char* error;
|
||||
Dart_Isolate isolate = Dart_CreateIsolate(
|
||||
NULL, NULL, bin::core_isolate_snapshot_data,
|
||||
bin::core_isolate_snapshot_instructions, NULL, NULL, NULL);
|
||||
bin::core_isolate_snapshot_instructions, NULL, NULL, &error);
|
||||
EXPECT_EQ(isolate, Dart_CurrentIsolate());
|
||||
EXPECT_EQ(error, static_cast<char*>(NULL));
|
||||
Dart_ShutdownIsolate();
|
||||
EXPECT_EQ(reinterpret_cast<Dart_Isolate>(NULL), Dart_CurrentIsolate());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue