| OLD | NEW |
| 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 Loading... |
| 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 } |
| OLD | NEW |