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

Side by Side Diff: src/core/SkRefDict.cpp

Issue 12440066: Fix minor valgrind-found memory leaks (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Addressed code review issues Created 7 years, 9 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 | « no previous file | src/effects/SkMatrixConvolutionImageFilter.cpp » ('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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkRefDict.h" 10 #include "SkRefDict.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 rec->fData->unref(); 52 rec->fData->unref();
53 rec->fData = data; 53 rec->fData = data;
54 } else { 54 } else {
55 // remove 55 // remove
56 rec->fData->unref(); 56 rec->fData->unref();
57 if (prev) { 57 if (prev) {
58 prev->fNext = rec->fNext; 58 prev->fNext = rec->fNext;
59 } else { 59 } else {
60 fImpl = rec->fNext; 60 fImpl = rec->fNext;
61 } 61 }
62 delete rec;
62 } 63 }
63 return; 64 return;
64 } 65 }
65 prev = rec; 66 prev = rec;
66 rec = rec->fNext; 67 rec = rec->fNext;
67 } 68 }
68 69
69 // if get here, name was not found, so add it 70 // if get here, name was not found, so add it
70 data->ref(); 71 data->ref();
71 rec = new Impl; 72 rec = new Impl;
72 rec->fName.set(name); 73 rec->fName.set(name);
73 rec->fData = data; 74 rec->fData = data;
74 // prepend to the head of our list 75 // prepend to the head of our list
75 rec->fNext = fImpl; 76 rec->fNext = fImpl;
76 fImpl = rec; 77 fImpl = rec;
77 } 78 }
78 79
79 void SkRefDict::removeAll() { 80 void SkRefDict::removeAll() {
80 Impl* rec = fImpl; 81 Impl* rec = fImpl;
81 while (rec) { 82 while (rec) {
82 Impl* next = rec->fNext; 83 Impl* next = rec->fNext;
83 rec->fData->unref(); 84 rec->fData->unref();
84 delete rec; 85 delete rec;
85 rec = next; 86 rec = next;
86 } 87 }
87 fImpl = NULL; 88 fImpl = NULL;
88 } 89 }
OLDNEW
« no previous file with comments | « no previous file | src/effects/SkMatrixConvolutionImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698