| Index: runtime/bin/extensions.cc
|
| diff --git a/runtime/bin/extensions.cc b/runtime/bin/extensions.cc
|
| index eaed7bb38b1a2775e30c4563bab40295d2888a53..7fa06fd64524cbeed4cff47b0c2f58b7ec3d1a4a 100644
|
| --- a/runtime/bin/extensions.cc
|
| +++ b/runtime/bin/extensions.cc
|
| @@ -6,12 +6,11 @@
|
|
|
| #include <stdio.h>
|
|
|
| +#include "bin/dartutils.h"
|
| +#include "bin/file.h"
|
| #include "include/dart_api.h"
|
| #include "platform/assert.h"
|
| #include "platform/globals.h"
|
| -#include "bin/dartutils.h"
|
| -#include "bin/file.h"
|
| -
|
|
|
| namespace dart {
|
| namespace bin {
|
| @@ -25,17 +24,15 @@ Dart_Handle Extensions::LoadExtension(const char* extension_directory,
|
| return Dart_NewApiError("Cannot load native extensions over http:");
|
| }
|
| const char* library_strings[] = { extension_directory, extension_file, NULL };
|
| - char* library_file = Concatenate(library_strings);
|
| + const char* library_file = Concatenate(library_strings);
|
| void* library_handle = LoadExtensionLibrary(library_file);
|
| - free(library_file);
|
| if (library_handle == NULL) {
|
| return GetError();
|
| }
|
|
|
| const char* strings[] = { extension_name, "_Init", NULL };
|
| - char* init_function_name = Concatenate(strings);
|
| + const char* init_function_name = Concatenate(strings);
|
| void* init_function = ResolveSymbol(library_handle, init_function_name);
|
| - free(init_function_name);
|
| Dart_Handle result = GetError();
|
| if (Dart_IsError(result)) {
|
| return result;
|
| @@ -48,13 +45,13 @@ Dart_Handle Extensions::LoadExtension(const char* extension_directory,
|
|
|
|
|
| // Concatenates a NULL terminated array of strings.
|
| -// The returned string must be freed.
|
| -char* Extensions::Concatenate(const char** strings) {
|
| +// The returned string is scope allocated.
|
| +const char* Extensions::Concatenate(const char** strings) {
|
| int size = 1; // null termination.
|
| for (int i = 0; strings[i] != NULL; i++) {
|
| size += strlen(strings[i]);
|
| }
|
| - char* result = reinterpret_cast<char*>(malloc(size));
|
| + char* result = reinterpret_cast<char*>(Dart_ScopeAllocate(size));
|
| int index = 0;
|
| for (int i = 0; strings[i] != NULL; i++) {
|
| index += snprintf(result + index, size - index, "%s", strings[i]);
|
|
|