aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-06-29 16:25:36 +0000
committerGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-06-29 16:25:36 +0000
commit4516f4786f5dda1b86a8f825b9e8e910d9c2363c (patch)
tree276d700f732a017cef1eadb8a8cf176c87e0bd0a
parent4b7577b042966657c776fd95c67f9363af57945f (diff)
use sk_bzero instead of bzero, since it isn't always available.
git-svn-id: http://skia.googlecode.com/svn/trunk@244 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--experimental/SkSetPoly3To3.cpp2
-rw-r--r--experimental/SkSetPoly3To3_A.cpp2
-rw-r--r--experimental/SkSetPoly3To3_D.cpp2
-rw-r--r--include/core/SkTypes.h5
-rw-r--r--samplecode/SamplePatch.cpp2
-rw-r--r--src/core/SkBitmap.cpp8
-rw-r--r--src/core/SkConcaveToTriangles.cpp2
-rw-r--r--src/core/SkDraw.cpp2
-rw-r--r--src/core/SkMatrix.cpp2
-rw-r--r--src/core/SkPictureFlat.cpp2
-rw-r--r--src/core/SkRect.cpp2
-rw-r--r--src/core/SkScalerContext.cpp10
-rw-r--r--src/gl/SkGL.cpp2
-rw-r--r--src/gl/SkGL.h4
-rw-r--r--src/gl/SkGLTextCache.cpp4
-rw-r--r--src/gl/SkTextureCache.cpp4
-rw-r--r--src/images/SkImageDecoder_libpvjpeg.cpp2
-rw-r--r--src/ports/SkFontHost_FreeType.cpp6
-rwxr-xr-xsrc/ports/SkFontHost_mac.cpp2
-rw-r--r--tests/Test.cpp2
20 files changed, 36 insertions, 31 deletions
diff --git a/experimental/SkSetPoly3To3.cpp b/experimental/SkSetPoly3To3.cpp
index 1420ebafd2..a19c5e57a5 100644
--- a/experimental/SkSetPoly3To3.cpp
+++ b/experimental/SkSetPoly3To3.cpp
@@ -3,7 +3,7 @@
static void computeOuterProduct(SkScalar op[4],
const SkPoint pts0[3], const SkPoint& ave0,
const SkPoint pts1[3], const SkPoint& ave1) {
- bzero(op, 4 * sizeof(op[0]));
+ sk_bzero(op, 4 * sizeof(op[0]));
for (int i = 0; i < 3; i++) {
SkScalar x0 = pts0[i].fX - ave0.fX;
SkScalar y0 = pts0[i].fY - ave0.fY;
diff --git a/experimental/SkSetPoly3To3_A.cpp b/experimental/SkSetPoly3To3_A.cpp
index cc953f59e5..d79703bf0d 100644
--- a/experimental/SkSetPoly3To3_A.cpp
+++ b/experimental/SkSetPoly3To3_A.cpp
@@ -31,7 +31,7 @@ static SkDScalar SkDScalar_setMul(SkScalar a, SkScalar b) {
static void computeOuterProduct(SkScalar op[4],
const SkPoint pts0[3], const SkPoint& ave0,
const SkPoint pts1[3], const SkPoint& ave1) {
- bzero(op, 4 * sizeof(op[0]));
+ sk_bzero(op, 4 * sizeof(op[0]));
for (int i = 0; i < 3; i++) {
SkScalar x0 = pts0[i].fX - ave0.fX;
SkScalar y0 = pts0[i].fY - ave0.fY;
diff --git a/experimental/SkSetPoly3To3_D.cpp b/experimental/SkSetPoly3To3_D.cpp
index 72ee9b115a..47c0946ed3 100644
--- a/experimental/SkSetPoly3To3_D.cpp
+++ b/experimental/SkSetPoly3To3_D.cpp
@@ -17,7 +17,7 @@ static void computeOuterProduct(SkMatrix* matrix,
const SkPoint pts0[3], const SkPoint& ave0,
const SkPoint pts1[3], const SkPoint& ave1) {
SkDScalar tmp[4];
- bzero(tmp, sizeof(tmp));
+ sk_bzero(tmp, sizeof(tmp));
for (int i = 0; i < 3; i++) {
SkScalar x0 = pts0[i].fX - ave0.fX;
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index 0554c73d12..00ecb6f4da 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -65,6 +65,11 @@ extern void* sk_realloc_throw(void* buffer, size_t size);
*/
extern void sk_free(void*);
+// bzero is safer than memset, but we can't rely on it, so... sk_bzero()
+static inline void sk_bzero(void* buffer, size_t size) {
+ memset(buffer, 0, size);
+}
+
///////////////////////////////////////////////////////////////////////
#define SK_INIT_TO_AVOID_WARNING = 0
diff --git a/samplecode/SamplePatch.cpp b/samplecode/SamplePatch.cpp
index 4669630237..3f898bc399 100644
--- a/samplecode/SamplePatch.cpp
+++ b/samplecode/SamplePatch.cpp
@@ -52,7 +52,7 @@ static SkShader* make_shader1(const SkIPoint& size) {
class Patch {
public:
- Patch() { bzero(fPts, sizeof(fPts)); }
+ Patch() { sk_bzero(fPts, sizeof(fPts)); }
~Patch() {}
void setPatch(const SkPoint pts[12]) {
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 2513b5147e..5ee4c5614b 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -84,12 +84,12 @@ struct SkBitmap::MipMap : SkNoncopyable {
///////////////////////////////////////////////////////////////////////////////
SkBitmap::SkBitmap() {
- bzero(this, sizeof(*this));
+ sk_bzero(this, sizeof(*this));
}
SkBitmap::SkBitmap(const SkBitmap& src) {
SkDEBUGCODE(src.validate();)
- bzero(this, sizeof(*this));
+ sk_bzero(this, sizeof(*this));
*this = src;
SkDEBUGCODE(this->validate();)
}
@@ -153,7 +153,7 @@ void SkBitmap::swap(SkBitmap& other) {
void SkBitmap::reset() {
this->freePixels();
- bzero(this, sizeof(*this));
+ sk_bzero(this, sizeof(*this));
}
int SkBitmap::ComputeBytesPerPixel(SkBitmap::Config config) {
@@ -1319,7 +1319,7 @@ void SkBitmap::unflatten(SkFlattenableReadBuffer& buffer) {
SkBitmap::RLEPixels::RLEPixels(int width, int height) {
fHeight = height;
fYPtrs = (uint8_t**)sk_malloc_throw(height * sizeof(uint8_t*));
- bzero(fYPtrs, height * sizeof(uint8_t*));
+ sk_bzero(fYPtrs, height * sizeof(uint8_t*));
}
SkBitmap::RLEPixels::~RLEPixels() {
diff --git a/src/core/SkConcaveToTriangles.cpp b/src/core/SkConcaveToTriangles.cpp
index efad5287d4..fa718e5096 100644
--- a/src/core/SkConcaveToTriangles.cpp
+++ b/src/core/SkConcaveToTriangles.cpp
@@ -687,7 +687,7 @@ bool ConvertPointsToVertices(size_t numPts, const SkPoint *pts, Vertex *vta) {
// Clear everything.
DebugPrintf("Zeroing vertices\n");
- bzero(vta, numPts * sizeof(*vta));
+ sk_bzero(vta, numPts * sizeof(*vta));
// Initialize vertices.
DebugPrintf("Initializing vertices\n");
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index fa3eb55a36..c4ea43a4cb 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -151,7 +151,7 @@ SkDraw::SkDraw(const SkDraw& src) {
typedef void (*BitmapXferProc)(void* pixels, size_t bytes, uint32_t data);
static void D_Clear_BitmapXferProc(void* pixels, size_t bytes, uint32_t) {
- bzero(pixels, bytes);
+ sk_bzero(pixels, bytes);
}
static void D_Dst_BitmapXferProc(void*, size_t, uint32_t data) {}
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp
index 48fa804d9b..3d2712b073 100644
--- a/src/core/SkMatrix.cpp
+++ b/src/core/SkMatrix.cpp
@@ -397,7 +397,7 @@ bool SkMatrix::setRectToRect(const SkRect& src, const SkRect& dst,
}
if (dst.isEmpty()) {
- bzero(fMat, 8 * sizeof(SkScalar));
+ sk_bzero(fMat, 8 * sizeof(SkScalar));
this->setTypeMask(kScale_Mask | kRectStaysRect_Mask);
} else {
SkScalar tx, sx = SkScalarDiv(dst.width(), src.width());
diff --git a/src/core/SkPictureFlat.cpp b/src/core/SkPictureFlat.cpp
index e221e55a20..3b02752a3f 100644
--- a/src/core/SkPictureFlat.cpp
+++ b/src/core/SkPictureFlat.cpp
@@ -246,7 +246,7 @@ void SkRefCntPlayback::setCount(int count) {
fCount = count;
fArray = SkNEW_ARRAY(SkRefCnt*, count);
- bzero(fArray, count * sizeof(SkRefCnt*));
+ sk_bzero(fArray, count * sizeof(SkRefCnt*));
}
SkRefCnt* SkRefCntPlayback::set(int index, SkRefCnt* obj) {
diff --git a/src/core/SkRect.cpp b/src/core/SkRect.cpp
index d602754c5b..7d7324920c 100644
--- a/src/core/SkRect.cpp
+++ b/src/core/SkRect.cpp
@@ -67,7 +67,7 @@ void SkRect::set(const SkPoint pts[], int count)
SkASSERT((pts && count > 0) || count == 0);
if (count <= 0) {
- bzero(this, sizeof(SkRect));
+ sk_bzero(this, sizeof(SkRect));
} else {
#ifdef SK_SCALAR_SLOW_COMPARES
int32_t l, t, r, b;
diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp
index cc3eb1aa25..7d66c2a5e6 100644
--- a/src/core/SkScalerContext.cpp
+++ b/src/core/SkScalerContext.cpp
@@ -334,7 +334,7 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph) {
glyph->toMask(&mask);
mask.fFormat = SkMask::kA8_Format;
- bzero(glyph->fImage, mask.computeImageSize());
+ sk_bzero(glyph->fImage, mask.computeImageSize());
if (!fRasterizer->rasterize(fillPath, fillToDevMatrix, NULL,
fMaskFilter, &mask,
@@ -364,7 +364,7 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph) {
bm.setConfig(config, glyph->fWidth, glyph->fHeight,
glyph->rowBytes());
bm.setPixels(glyph->fImage);
- bzero(glyph->fImage, bm.height() * bm.rowBytes());
+ sk_bzero(glyph->fImage, bm.height() * bm.rowBytes());
draw.fClip = &clip;
draw.fMatrix = &matrix;
@@ -400,7 +400,7 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph) {
}
// clean out our glyph, since it may be larger than dstM
- //bzero(dst, height * dstRB);
+ //sk_bzero(dst, height * dstRB);
while (--height >= 0) {
memcpy(dst, src, width);
@@ -576,10 +576,10 @@ protected:
virtual void generateFontMetrics(SkPaint::FontMetrics* mx,
SkPaint::FontMetrics* my) {
if (mx) {
- bzero(mx, sizeof(*mx));
+ sk_bzero(mx, sizeof(*mx));
}
if (my) {
- bzero(my, sizeof(*my));
+ sk_bzero(my, sizeof(*my));
}
}
};
diff --git a/src/gl/SkGL.cpp b/src/gl/SkGL.cpp
index 89bcdf4bc2..1fce98f82c 100644
--- a/src/gl/SkGL.cpp
+++ b/src/gl/SkGL.cpp
@@ -120,7 +120,7 @@ void SkGL::Ortho(float left, float right, float bottom, float top,
float mat[16];
- bzero(mat, sizeof(mat));
+ sk_bzero(mat, sizeof(mat));
mat[0] = 2 / (right - left);
mat[5] = 2 / (top - bottom);
diff --git a/src/gl/SkGL.h b/src/gl/SkGL.h
index dd2c77f880..9f79ad16fc 100644
--- a/src/gl/SkGL.h
+++ b/src/gl/SkGL.h
@@ -193,12 +193,12 @@ struct SkGLMatrix {
SkGLScalar fMat[16];
void reset() {
- bzero(fMat, sizeof(fMat));
+ sk_bzero(fMat, sizeof(fMat));
fMat[0] = fMat[5] = fMat[10] = fMat[15] = SK_GLScalar1;
}
void set(const SkMatrix& m) {
- bzero(fMat, sizeof(fMat));
+ sk_bzero(fMat, sizeof(fMat));
fMat[0] = SkScalarToGL(m[SkMatrix::kMScaleX]);
fMat[4] = SkScalarToGL(m[SkMatrix::kMSkewX]);
fMat[12] = SkScalarToGL(m[SkMatrix::kMTransX]);
diff --git a/src/gl/SkGLTextCache.cpp b/src/gl/SkGLTextCache.cpp
index 141e1001e4..2619dc82e9 100644
--- a/src/gl/SkGLTextCache.cpp
+++ b/src/gl/SkGLTextCache.cpp
@@ -127,7 +127,7 @@ SkGLTextCache::Strike::addGlyphAndBind(const SkGlyph& glyph,
///////////////////////////////////////////////////////////////////////////////
SkGLTextCache::SkGLTextCache() {
- bzero(fStrikeList, sizeof(fStrikeList));
+ sk_bzero(fStrikeList, sizeof(fStrikeList));
}
SkGLTextCache::~SkGLTextCache() {
@@ -146,7 +146,7 @@ void SkGLTextCache::deleteAllStrikes(bool texturesAreValid) {
strike = next;
}
}
- bzero(fStrikeList, sizeof(fStrikeList));
+ sk_bzero(fStrikeList, sizeof(fStrikeList));
}
SkGLTextCache::Strike* SkGLTextCache::findGlyph(const SkGlyph& glyph,
diff --git a/src/gl/SkTextureCache.cpp b/src/gl/SkTextureCache.cpp
index 17b37cae4e..2eb5d84e36 100644
--- a/src/gl/SkTextureCache.cpp
+++ b/src/gl/SkTextureCache.cpp
@@ -23,7 +23,7 @@ SkTextureCache::SkTextureCache(size_t countMax, size_t sizeMax)
fTexCountMax(countMax), fTexSizeMax(sizeMax),
fTexCount(0), fTexSize(0) {
- bzero(fHash, sizeof(fHash));
+ sk_bzero(fHash, sizeof(fHash));
this->validate();
}
@@ -52,7 +52,7 @@ void SkTextureCache::deleteAllCaches(bool texturesAreValid) {
}
fSorted.reset();
- bzero(fHash, sizeof(fHash));
+ sk_bzero(fHash, sizeof(fHash));
fTexCount = 0;
fTexSize = 0;
diff --git a/src/images/SkImageDecoder_libpvjpeg.cpp b/src/images/SkImageDecoder_libpvjpeg.cpp
index 91777418b2..b98763e6c9 100644
--- a/src/images/SkImageDecoder_libpvjpeg.cpp
+++ b/src/images/SkImageDecoder_libpvjpeg.cpp
@@ -107,7 +107,7 @@ static bool getFrame(PVJpgDecoderInterface* codec, SkBitmap* bitmap,
TPvJpgDecFrame frame;
uint8* ptrs[3];
int32 widths[3], heights[3];
- bzero(ptrs, sizeof(ptrs));
+ sk_bzero(ptrs, sizeof(ptrs));
frame.ptr = ptrs;
frame.iWidth = widths;
frame.iHeight = heights;
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index 7aa14b252e..b30aba53fb 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -156,7 +156,7 @@ SkFaceRec::SkFaceRec(SkStream* strm, uint32_t fontID)
: fSkStream(strm), fFontID(fontID) {
// SkDEBUGF(("SkFaceRec: opening %s (%p)\n", key.c_str(), strm));
- bzero(&fFTStream, sizeof(fFTStream));
+ sk_bzero(&fFTStream, sizeof(fFTStream));
fFTStream.size = fSkStream->getLength();
fFTStream.descriptor.pointer = fSkStream;
fFTStream.read = sk_stream_read;
@@ -754,10 +754,10 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx,
if (this->setupSize()) {
ERROR:
if (mx) {
- bzero(mx, sizeof(SkPaint::FontMetrics));
+ sk_bzero(mx, sizeof(SkPaint::FontMetrics));
}
if (my) {
- bzero(my, sizeof(SkPaint::FontMetrics));
+ sk_bzero(my, sizeof(SkPaint::FontMetrics));
}
return;
}
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index e9dfc6a852..5deae35491 100755
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -251,7 +251,7 @@ void SkScalerContext_Mac::generateImage(const SkGlyph& glyph)
SkAutoMutexAcquire ac(gFTMutex);
SkASSERT(fLayout);
- bzero(glyph.fImage, glyph.fHeight * glyph.rowBytes());
+ sk_bzero(glyph.fImage, glyph.fHeight * glyph.rowBytes());
CGContextRef contextRef = ::CGBitmapContextCreate(glyph.fImage,
glyph.fWidth, glyph.fHeight, 8,
glyph.rowBytes(), fGrayColorSpace,
diff --git a/tests/Test.cpp b/tests/Test.cpp
index 2de0183b98..4bbe83a33d 100644
--- a/tests/Test.cpp
+++ b/tests/Test.cpp
@@ -9,7 +9,7 @@ Reporter::Reporter() {
void Reporter::resetReporting() {
fCurrTest = NULL;
fTestCount = 0;
- bzero(fResultCount, sizeof(fResultCount));
+ sk_bzero(fResultCount, sizeof(fResultCount));
}
void Reporter::startTest(Test* test) {