Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Side by Side Diff: runtime/bin/extensions.cc

Issue 11308170: Deal with extension loading from packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/builtin.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/extensions.h" 5 #include "bin/extensions.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "include/dart_api.h" 9 #include "include/dart_api.h"
10 #include "platform/assert.h" 10 #include "platform/assert.h"
11 #include "platform/globals.h" 11 #include "platform/globals.h"
12 #include "bin/dartutils.h" 12 #include "bin/dartutils.h"
13 #include "bin/file.h" 13 #include "bin/file.h"
14 14
15 Dart_Handle Extensions::LoadExtension(const char* extension_url, 15 Dart_Handle Extensions::LoadExtension(const char* extension_url,
16 Dart_Handle parent_library) { 16 Dart_Handle parent_library) {
17 char* library_path = strdup(extension_url); 17 char* library_path = strdup(extension_url);
18 if (!library_path || !File::IsAbsolutePath(library_path)) { 18
Bill Hesse 2012/11/22 16:18:41 Do we really want unchecked malloc (strdup) to go
Mads Ager (google) 2012/11/23 07:07:40 It would be nicer to deal with it although in gene
19 free(library_path);
20 return Dart_Error("unexpected error in library path");
21 }
22 // Extract the path and the extension name from the url. 19 // Extract the path and the extension name from the url.
23 char* last_path_separator = strrchr(library_path, '/'); 20 char* last_path_separator = strrchr(library_path, '/');
24 char* extension_name = last_path_separator + 1; 21 char* extension_name = last_path_separator + 1;
25 *last_path_separator = '\0'; // Terminate library_path at last separator. 22 *last_path_separator = '\0'; // Terminate library_path at last separator.
26 23
27 void* library_handle = LoadExtensionLibrary(library_path, extension_name); 24 void* library_handle = LoadExtensionLibrary(library_path, extension_name);
28 if (!library_handle) { 25 if (!library_handle) {
29 free(library_path); 26 free(library_path);
30 return Dart_Error("cannot find extension library"); 27 return Dart_Error("cannot find extension library");
31 } 28 }
(...skipping 22 matching lines...) Expand all
54 } 51 }
55 char* result = reinterpret_cast<char*>(malloc(size)); 52 char* result = reinterpret_cast<char*>(malloc(size));
56 int index = 0; 53 int index = 0;
57 for (int i = 0; strings[i] != NULL; i++) { 54 for (int i = 0; strings[i] != NULL; i++) {
58 index += snprintf(result + index, size - index, "%s", strings[i]); 55 index += snprintf(result + index, size - index, "%s", strings[i]);
59 } 56 }
60 ASSERT(index == size - 1); 57 ASSERT(index == size - 1);
61 ASSERT(result[size - 1] == '\0'); 58 ASSERT(result[size - 1] == '\0');
62 return result; 59 return result;
63 } 60 }
OLDNEW
« no previous file with comments | « runtime/bin/builtin.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698