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

Side by Side Diff: src/utils/SkBitSet.cpp

Issue 13146005: Fix minor cppcheck-found issues (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 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
« src/utils/SkBitSet.h ('K') | « src/utils/SkBitSet.h ('k') | 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 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 "SkBitSet.h" 10 #include "SkBitSet.h"
11 11
12 SkBitSet::SkBitSet(int numberOfBits) 12 SkBitSet::SkBitSet(int numberOfBits)
13 : fBitData(NULL), fDwordCount(0), fBitCount(numberOfBits) { 13 : fBitData(NULL), fDwordCount(0), fBitCount(numberOfBits) {
14 SkASSERT(numberOfBits > 0); 14 SkASSERT(numberOfBits > 0);
15 // Round up size to 32-bit boundary. 15 // Round up size to 32-bit boundary.
16 fDwordCount = (numberOfBits + 31) / 32; 16 fDwordCount = (numberOfBits + 31) / 32;
17 fBitData.set(malloc(fDwordCount * sizeof(uint32_t))); 17 fBitData.set(malloc(fDwordCount * sizeof(uint32_t)));
18 clearAll(); 18 clearAll();
19 } 19 }
20 20
21 SkBitSet::SkBitSet(const SkBitSet& source) 21 SkBitSet::SkBitSet(const SkBitSet& source)
22 : fBitData(NULL), fDwordCount(0), fBitCount(0) { 22 : fBitData(NULL), fDwordCount(0), fBitCount(0) {
23 *this = source; 23 *this = source;
24 } 24 }
25 25
26 const SkBitSet& SkBitSet::operator=(const SkBitSet& rhs) { 26 SkBitSet& SkBitSet::operator=(const SkBitSet& rhs) {
27 if (this == &rhs) { 27 if (this == &rhs) {
28 return *this; 28 return *this;
29 } 29 }
30 fBitCount = rhs.fBitCount; 30 fBitCount = rhs.fBitCount;
31 fBitData.free(); 31 fBitData.free();
32 fDwordCount = rhs.fDwordCount; 32 fDwordCount = rhs.fDwordCount;
33 fBitData.set(malloc(fDwordCount * sizeof(uint32_t))); 33 fBitData.set(malloc(fDwordCount * sizeof(uint32_t)));
34 memcpy(fBitData.get(), rhs.fBitData.get(), fDwordCount * sizeof(uint32_t)); 34 memcpy(fBitData.get(), rhs.fBitData.get(), fDwordCount * sizeof(uint32_t));
35 return *this; 35 return *this;
36 } 36 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 if (fBitCount != source.fBitCount) { 74 if (fBitCount != source.fBitCount) {
75 return false; 75 return false;
76 } 76 }
77 uint32_t* targetBitmap = internalGet(0); 77 uint32_t* targetBitmap = internalGet(0);
78 uint32_t* sourceBitmap = source.internalGet(0); 78 uint32_t* sourceBitmap = source.internalGet(0);
79 for (size_t i = 0; i < fDwordCount; ++i) { 79 for (size_t i = 0; i < fDwordCount; ++i) {
80 targetBitmap[i] |= sourceBitmap[i]; 80 targetBitmap[i] |= sourceBitmap[i];
81 } 81 }
82 return true; 82 return true;
83 } 83 }
OLDNEW
« src/utils/SkBitSet.h ('K') | « src/utils/SkBitSet.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698