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

Side by Side Diff: src/regexp-stack.cc

Issue 11275037: Fix memory leak in RegExpStack. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month 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 | « no previous file | 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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 66
67 char* RegExpStack::RestoreStack(char* from) { 67 char* RegExpStack::RestoreStack(char* from) {
68 size_t size = sizeof(thread_local_); 68 size_t size = sizeof(thread_local_);
69 memcpy(&thread_local_, reinterpret_cast<void*>(from), size); 69 memcpy(&thread_local_, reinterpret_cast<void*>(from), size);
70 return from + size; 70 return from + size;
71 } 71 }
72 72
73 73
74 void RegExpStack::Reset() { 74 void RegExpStack::Reset() {
75 if (thread_local_.memory_size_ > kMinimumStackSize) { 75 if (thread_local_.memory_size_ >= kMinimumStackSize) {
76 DeleteArray(thread_local_.memory_); 76 DeleteArray(thread_local_.memory_);
77 thread_local_ = ThreadLocal(); 77 thread_local_ = ThreadLocal();
78 } 78 }
79 } 79 }
80 80
81 81
82 void RegExpStack::ThreadLocal::Free() { 82 void RegExpStack::ThreadLocal::Free() {
83 if (memory_size_ > 0) { 83 if (memory_size_ > 0) {
84 DeleteArray(memory_); 84 DeleteArray(memory_);
85 Clear(); 85 Clear();
(...skipping 16 matching lines...) Expand all
102 } 102 }
103 thread_local_.memory_ = new_memory; 103 thread_local_.memory_ = new_memory;
104 thread_local_.memory_size_ = size; 104 thread_local_.memory_size_ = size;
105 thread_local_.limit_ = new_memory + kStackLimitSlack * kPointerSize; 105 thread_local_.limit_ = new_memory + kStackLimitSlack * kPointerSize;
106 } 106 }
107 return thread_local_.memory_ + thread_local_.memory_size_; 107 return thread_local_.memory_ + thread_local_.memory_size_;
108 } 108 }
109 109
110 110
111 }} // namespace v8::internal 111 }} // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698