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

Side by Side Diff: webrtc/system_wrappers/include/ref_count.h

Issue 1465113002: Fix memory leak in vcm_capturer.cc. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: modify ref_count.h, init ref_count to 1 after new Created 5 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
« no previous file with comments | « no previous file | webrtc/test/vcm_capturer.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 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 25 matching lines...) Expand all
36 // }; 36 // };
37 // MyImplementation* CreateMyImplementation() { 37 // MyImplementation* CreateMyImplementation() {
38 // RefCountImpl<MyImplementation>* implementation = 38 // RefCountImpl<MyImplementation>* implementation =
39 // new RefCountImpl<MyImplementation>(); 39 // new RefCountImpl<MyImplementation>();
40 // return implementation; 40 // return implementation;
41 // } 41 // }
42 42
43 template <class T> 43 template <class T>
44 class RefCountImpl : public T { 44 class RefCountImpl : public T {
45 public: 45 public:
46 RefCountImpl() : ref_count_(0) {} 46 RefCountImpl() : ref_count_(1) {}
47 47
48 template<typename P> 48 template<typename P>
49 explicit RefCountImpl(P p) : T(p), ref_count_(0) {} 49 explicit RefCountImpl(P p) : T(p), ref_count_(1) {}
50 50
51 template<typename P1, typename P2> 51 template<typename P1, typename P2>
52 RefCountImpl(P1 p1, P2 p2) : T(p1, p2), ref_count_(0) {} 52 RefCountImpl(P1 p1, P2 p2) : T(p1, p2), ref_count_(1) {}
53 53
54 template<typename P1, typename P2, typename P3> 54 template<typename P1, typename P2, typename P3>
55 RefCountImpl(P1 p1, P2 p2, P3 p3) : T(p1, p2, p3), ref_count_(0) {} 55 RefCountImpl(P1 p1, P2 p2, P3 p3) : T(p1, p2, p3), ref_count_(1) {}
56 56
57 template<typename P1, typename P2, typename P3, typename P4> 57 template<typename P1, typename P2, typename P3, typename P4>
58 RefCountImpl(P1 p1, P2 p2, P3 p3, P4 p4) : T(p1, p2, p3, p4), ref_count_(0) {} 58 RefCountImpl(P1 p1, P2 p2, P3 p3, P4 p4) : T(p1, p2, p3, p4), ref_count_(1) {}
59 59
60 template<typename P1, typename P2, typename P3, typename P4, typename P5> 60 template<typename P1, typename P2, typename P3, typename P4, typename P5>
61 RefCountImpl(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) 61 RefCountImpl(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
62 : T(p1, p2, p3, p4, p5), ref_count_(0) {} 62 : T(p1, p2, p3, p4, p5), ref_count_(1) {}
63 63
64 int32_t AddRef() const override { 64 int32_t AddRef() const override {
65 return ++ref_count_; 65 return ++ref_count_;
66 } 66 }
67 67
68 int32_t Release() const override { 68 int32_t Release() const override {
69 int32_t ref_count; 69 int32_t ref_count;
70 ref_count = --ref_count_; 70 ref_count = --ref_count_;
71 if (ref_count == 0) 71 if (ref_count == 0)
72 delete this; 72 delete this;
73 return ref_count; 73 return ref_count;
74 } 74 }
75 75
76 protected: 76 protected:
77 mutable Atomic32 ref_count_; 77 mutable Atomic32 ref_count_;
78 }; 78 };
79 79
80 } // namespace webrtc 80 } // namespace webrtc
81 81
82 #endif // SYSTEM_WRAPPERS_INCLUDE_REF_COUNT_H_ 82 #endif // SYSTEM_WRAPPERS_INCLUDE_REF_COUNT_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/test/vcm_capturer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698