Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: include/AdblockPlus/V8ValueHolder.h

Issue 12647002: Fix memory leaks in libadblockplus (Closed)
Patch Set: Created Oct. 6, 2013, 10:21 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/FilterEngine.cpp » ('j') | src/FilterEngine.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 reset(value.isolate, static_cast<v8::Handle<T> >(value)); 42 reset(value.isolate, static_cast<v8::Handle<T> >(value));
43 } 43 }
44 V8ValueHolder(v8::Isolate* isolate, v8::Persistent<T> value) 44 V8ValueHolder(v8::Isolate* isolate, v8::Persistent<T> value)
45 { 45 {
46 reset(isolate, value); 46 reset(isolate, value);
47 } 47 }
48 V8ValueHolder(v8::Isolate* isolate, v8::Handle<T> value) 48 V8ValueHolder(v8::Isolate* isolate, v8::Handle<T> value)
49 { 49 {
50 reset(isolate, value); 50 reset(isolate, value);
51 } 51 }
52 52 ~V8ValueHolder()
53 {
54 if (this->value.get())
55 {
56 this->value->Dispose(this->isolate);
57 this->value.reset(0);
58 }
Wladimir Palant 2013/10/08 08:12:19 Better avoid the code duplication here: reset(0,
59 }
53 void reset(v8::Isolate* isolate, v8::Persistent<T> value) 60 void reset(v8::Isolate* isolate, v8::Persistent<T> value)
54 { 61 {
55 if (this->value.get()) 62 if (this->value.get())
56 { 63 {
57 this->value->Dispose(this->isolate); 64 this->value->Dispose(this->isolate);
58 this->value.reset(0); 65 this->value.reset(0);
59 } 66 }
60 67
61 if (!value.IsEmpty()) 68 if (!value.IsEmpty())
62 { 69 {
(...skipping 19 matching lines...) Expand all
82 { 89 {
83 return *value; 90 return *value;
84 } 91 }
85 private: 92 private:
86 v8::Isolate* isolate; 93 v8::Isolate* isolate;
87 std::auto_ptr<v8::Persistent<T> > value; 94 std::auto_ptr<v8::Persistent<T> > value;
88 }; 95 };
89 } 96 }
90 97
91 #endif 98 #endif
OLDNEW
« no previous file with comments | « no previous file | src/FilterEngine.cpp » ('j') | src/FilterEngine.cpp » ('J')

Powered by Google App Engine
This is Rietveld