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

Side by Side Diff: runtime/vm/code_observers.cc

Issue 16271010: Use 'new' in all the snapshot reallocation functions instead of realloc. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/class_table.cc ('k') | runtime/vm/dart_api_impl.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 (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 "vm/code_observers.h" 5 #include "vm/code_observers.h"
6 6
7 #include "platform/utils.h"
7 #include "vm/os.h" 8 #include "vm/os.h"
8 9
9 namespace dart { 10 namespace dart {
10 11
11 intptr_t CodeObservers::observers_length_ = 0; 12 intptr_t CodeObservers::observers_length_ = 0;
12 CodeObserver** CodeObservers::observers_ = NULL; 13 CodeObserver** CodeObservers::observers_ = NULL;
13 14
14 15
15 void CodeObservers::Register(CodeObserver* observer) { 16 void CodeObservers::Register(CodeObserver* observer) {
16 observers_length_++; 17 intptr_t new_length = observers_length_ + 1;
17 observers_ = reinterpret_cast<CodeObserver**>( 18 observers_ = Utils::Realloc(observers_, observers_length_, new_length);
18 realloc(observers_, sizeof(observer) * observers_length_));
19 if (observers_ == NULL) { 19 if (observers_ == NULL) {
20 FATAL("failed to grow code observers array"); 20 FATAL("failed to grow code observers array");
21 } 21 }
22 observers_length_ = new_length;
22 observers_[observers_length_ - 1] = observer; 23 observers_[observers_length_ - 1] = observer;
23 } 24 }
24 25
25 26
26 void CodeObservers::NotifyAll(const char* name, 27 void CodeObservers::NotifyAll(const char* name,
27 uword base, 28 uword base,
28 uword prologue_offset, 29 uword prologue_offset,
29 uword size, 30 uword size,
30 bool optimized) { 31 bool optimized) {
31 ASSERT(!AreActive() || (strlen(name) != 0)); 32 ASSERT(!AreActive() || (strlen(name) != 0));
(...skipping 20 matching lines...) Expand all
52 free(observers_); 53 free(observers_);
53 } 54 }
54 55
55 56
56 void CodeObservers::InitOnce() { 57 void CodeObservers::InitOnce() {
57 OS::RegisterCodeObservers(); 58 OS::RegisterCodeObservers();
58 } 59 }
59 60
60 61
61 } // namespace dart 62 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/class_table.cc ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698