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

Side by Side Diff: src/platform-macos.cc

Issue 1737023: Turn some usages of NewArray with DeleteArray in the same scope into ScopedVector or SmartPointer. (Closed)
Patch Set: Disabling implicit constructors Created 10 years, 7 months 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
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-solaris.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 (t->tm_isdst > 0 ? 3600 * msPerSecond : 0)); 276 (t->tm_isdst > 0 ? 3600 * msPerSecond : 0));
277 } 277 }
278 278
279 279
280 int OS::StackWalk(Vector<StackFrame> frames) { 280 int OS::StackWalk(Vector<StackFrame> frames) {
281 // If weak link to execinfo lib has failed, ie because we are on 10.4, abort. 281 // If weak link to execinfo lib has failed, ie because we are on 10.4, abort.
282 if (backtrace == NULL) 282 if (backtrace == NULL)
283 return 0; 283 return 0;
284 284
285 int frames_size = frames.length(); 285 int frames_size = frames.length();
286 void** addresses = NewArray<void*>(frames_size); 286 ScopedVector<void*> addresses(frames_size);
287 int frames_count = backtrace(addresses, frames_size);
288 287
289 char** symbols; 288 int frames_count = backtrace(addresses.start(), frames_size.start());
290 symbols = backtrace_symbols(addresses, frames_count); 289
290 char** symbols = backtrace_symbols(addresses.start(), frames_count);
291 if (symbols == NULL) { 291 if (symbols == NULL) {
292 DeleteArray(addresses);
293 return kStackWalkError; 292 return kStackWalkError;
294 } 293 }
295 294
296 for (int i = 0; i < frames_count; i++) { 295 for (int i = 0; i < frames_count; i++) {
297 frames[i].address = addresses[i]; 296 frames[i].address = addresses[i];
298 // Format a text representation of the frame based on the information 297 // Format a text representation of the frame based on the information
299 // available. 298 // available.
300 SNPrintF(MutableCStrVector(frames[i].text, 299 SNPrintF(MutableCStrVector(frames[i].text,
301 kStackWalkMaxTextLen), 300 kStackWalkMaxTextLen),
302 "%s", 301 "%s",
303 symbols[i]); 302 symbols[i]);
304 // Make sure line termination is in place. 303 // Make sure line termination is in place.
305 frames[i].text[kStackWalkMaxTextLen - 1] = '\0'; 304 frames[i].text[kStackWalkMaxTextLen - 1] = '\0';
306 } 305 }
307 306
308 DeleteArray(addresses);
309 free(symbols); 307 free(symbols);
310 308
311 return frames_count; 309 return frames_count;
312 } 310 }
313 311
314 312
315 313
316 314
317 VirtualMemory::VirtualMemory(size_t size) { 315 VirtualMemory::VirtualMemory(size_t size) {
318 address_ = mmap(NULL, size, PROT_NONE, 316 address_ = mmap(NULL, size, PROT_NONE,
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 649
652 // Deallocate Mach port for thread. 650 // Deallocate Mach port for thread.
653 if (IsProfiling()) { 651 if (IsProfiling()) {
654 mach_port_deallocate(data_->task_self_, data_->profiled_thread_); 652 mach_port_deallocate(data_->task_self_, data_->profiled_thread_);
655 } 653 }
656 } 654 }
657 655
658 #endif // ENABLE_LOGGING_AND_PROFILING 656 #endif // ENABLE_LOGGING_AND_PROFILING
659 657
660 } } // namespace v8::internal 658 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-solaris.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698