From dd8ebc5bd148b732b7e1b207c2f7ef43ce9ebb3a Mon Sep 17 00:00:00 2001 From: "cathleen%netscape.com" Date: Wed, 30 Jan 2002 02:55:57 +0000 Subject: [PATCH] eliminate nsCRT::zero() to use memset to zero instead, bug 118135, r=dp sr=waterson git-svn-id: svn://10.0.0.236/trunk@113183 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/events/src/nsDOMEvent.cpp | 2 +- mozilla/content/shared/src/nsStyleStruct.cpp | 8 ++++---- mozilla/gfx/src/mac/nsMacUnicodeFontInfo.cpp | 2 +- mozilla/gfx/src/windows/nsDrawingSurfaceWin.cpp | 2 +- mozilla/htmlparser/src/nsDTDUtils.cpp | 2 +- mozilla/layout/base/nsBidiPresUtils.cpp | 4 ++-- mozilla/layout/base/src/nsBidiPresUtils.cpp | 4 ++-- mozilla/layout/generic/nsBidiFrames.cpp | 2 +- mozilla/layout/generic/nsFrame.cpp | 4 ++-- mozilla/layout/html/base/src/nsBidiFrames.cpp | 2 +- mozilla/layout/html/base/src/nsFrame.cpp | 4 ++-- mozilla/layout/style/nsStyleStruct.cpp | 8 ++++---- mozilla/layout/xul/base/src/nsBoxLayoutState.cpp | 2 +- mozilla/netwerk/cache/src/nsDiskCacheBlockFile.cpp | 2 +- mozilla/netwerk/cache/src/nsDiskCacheEntry.cpp | 2 +- mozilla/netwerk/cache/src/nsDiskCacheMap.cpp | 4 ++-- .../netwerk/streamconv/src/nsAppleFileDecoder.cpp | 10 +++++----- mozilla/parser/htmlparser/src/nsDTDUtils.cpp | 2 +- .../uriloader/exthandler/mac/nsDecodeAppleFile.cpp | 10 +++++----- mozilla/xpcom/ds/nsCRT.h | 12 ++++++------ mozilla/xpcom/ds/nsDeque.cpp | 4 ++-- 21 files changed, 46 insertions(+), 46 deletions(-) diff --git a/mozilla/content/events/src/nsDOMEvent.cpp b/mozilla/content/events/src/nsDOMEvent.cpp index a90ef84c2d2..1280f8dd7a0 100644 --- a/mozilla/content/events/src/nsDOMEvent.cpp +++ b/mozilla/content/events/src/nsDOMEvent.cpp @@ -117,7 +117,7 @@ nsDOMEvent::operator new(size_t aSize) } if (result) { - nsCRT::zero(result, aSize); + memset(result, 0, aSize); } return result; diff --git a/mozilla/content/shared/src/nsStyleStruct.cpp b/mozilla/content/shared/src/nsStyleStruct.cpp index 5e9b21d6a08..6bb90e8e8c7 100644 --- a/mozilla/content/shared/src/nsStyleStruct.cpp +++ b/mozilla/content/shared/src/nsStyleStruct.cpp @@ -238,7 +238,7 @@ nsStyleFont::operator new(size_t sz, nsIPresContext* aContext) { void* result = nsnull; aContext->AllocateFromShell(sz, &result); if (result) - nsCRT::zero(result, sz); + memset(result, 0, sz); return result; } @@ -319,7 +319,7 @@ nsStyleMargin::operator new(size_t sz, nsIPresContext* aContext) { void* result = nsnull; aContext->AllocateFromShell(sz, &result); if (result) - nsCRT::zero(result, sz); + memset(result, 0, sz); return result; } @@ -378,7 +378,7 @@ nsStylePadding::operator new(size_t sz, nsIPresContext* aContext) { void* result = nsnull; aContext->AllocateFromShell(sz, &result); if (result) - nsCRT::zero(result, sz); + memset(result, 0, sz); return result; } @@ -478,7 +478,7 @@ nsStyleBorder::operator new(size_t sz, nsIPresContext* aContext) { void* result = nsnull; aContext->AllocateFromShell(sz, &result); if (result) - nsCRT::zero(result, sz); + memset(result, 0, sz); return result; } diff --git a/mozilla/gfx/src/mac/nsMacUnicodeFontInfo.cpp b/mozilla/gfx/src/mac/nsMacUnicodeFontInfo.cpp index e8cb5b66c07..9799d7c826a 100644 --- a/mozilla/gfx/src/mac/nsMacUnicodeFontInfo.cpp +++ b/mozilla/gfx/src/mac/nsMacUnicodeFontInfo.cpp @@ -398,7 +398,7 @@ static PRBool FillFontInfoFromCMAP(FMFont aFont, PRUint32 *aFontInfo, FourCharCo static PRUint16* InitGlobalCCMap() { PRUint32 info[2048]; - nsCRT::zero(info, sizeof(info)); + memset(info, 0, sizeof(info)); #ifdef TRACK_INIT_PERFORMANCE AbsoluteTime startTime; diff --git a/mozilla/gfx/src/windows/nsDrawingSurfaceWin.cpp b/mozilla/gfx/src/windows/nsDrawingSurfaceWin.cpp index 1aaba5dd03b..3c8e98c74a2 100644 --- a/mozilla/gfx/src/windows/nsDrawingSurfaceWin.cpp +++ b/mozilla/gfx/src/windows/nsDrawingSurfaceWin.cpp @@ -629,7 +629,7 @@ BITMAPINFO * nsDrawingSurfaceWin :: CreateBitmapInfo(PRInt32 aWidth, PRInt32 aHe if ((aDepth == 16) || (aDepth == 32)) memcpy(colortable, masks, sizeof(DWORD) * allocsize); else - nsCRT::zero(colortable, sizeof(RGBQUAD) * palsize); + memset(colortable, 0, sizeof(RGBQUAD) * palsize); if (nsnull != aBits) *aBits = PR_Malloc(imagesize); diff --git a/mozilla/htmlparser/src/nsDTDUtils.cpp b/mozilla/htmlparser/src/nsDTDUtils.cpp index fa59b793200..e52d467fddf 100644 --- a/mozilla/htmlparser/src/nsDTDUtils.cpp +++ b/mozilla/htmlparser/src/nsDTDUtils.cpp @@ -1489,7 +1489,7 @@ NS_IMPL_ISUPPORTS1(nsObserverEntry, nsIObserverEntry) nsObserverEntry::nsObserverEntry(const nsAString& aTopic) : mTopic(aTopic) { NS_INIT_ISUPPORTS(); - nsCRT::zero(mObservers,sizeof(mObservers)); + memset(mObservers, 0, sizeof(mObservers)); } nsObserverEntry::~nsObserverEntry() { diff --git a/mozilla/layout/base/nsBidiPresUtils.cpp b/mozilla/layout/base/nsBidiPresUtils.cpp index 448b991cb12..b1989975bf7 100644 --- a/mozilla/layout/base/nsBidiPresUtils.cpp +++ b/mozilla/layout/base/nsBidiPresUtils.cpp @@ -525,7 +525,7 @@ nsBidiPresUtils::Reorder(nsIPresContext* aPresContext, return NS_ERROR_OUT_OF_MEMORY; } } - nsCRT::zero(mLevels, sizeof(PRUint8) * mArraySize); + memset(mLevels, 0, sizeof(PRUint8) * mArraySize); nsIFrame* frame; PRInt32 i; @@ -542,7 +542,7 @@ nsBidiPresUtils::Reorder(nsIPresContext* aPresContext, mSuccess = NS_ERROR_OUT_OF_MEMORY; } else { - nsCRT::zero(mIndexMap, sizeof(PRUint32) * mArraySize); + memset(mIndexMap, 0, sizeof(PRUint32) * mArraySize); mSuccess = mBidiEngine->ReorderVisual(mLevels, count, mIndexMap); diff --git a/mozilla/layout/base/src/nsBidiPresUtils.cpp b/mozilla/layout/base/src/nsBidiPresUtils.cpp index 448b991cb12..b1989975bf7 100644 --- a/mozilla/layout/base/src/nsBidiPresUtils.cpp +++ b/mozilla/layout/base/src/nsBidiPresUtils.cpp @@ -525,7 +525,7 @@ nsBidiPresUtils::Reorder(nsIPresContext* aPresContext, return NS_ERROR_OUT_OF_MEMORY; } } - nsCRT::zero(mLevels, sizeof(PRUint8) * mArraySize); + memset(mLevels, 0, sizeof(PRUint8) * mArraySize); nsIFrame* frame; PRInt32 i; @@ -542,7 +542,7 @@ nsBidiPresUtils::Reorder(nsIPresContext* aPresContext, mSuccess = NS_ERROR_OUT_OF_MEMORY; } else { - nsCRT::zero(mIndexMap, sizeof(PRUint32) * mArraySize); + memset(mIndexMap, 0, sizeof(PRUint32) * mArraySize); mSuccess = mBidiEngine->ReorderVisual(mLevels, count, mIndexMap); diff --git a/mozilla/layout/generic/nsBidiFrames.cpp b/mozilla/layout/generic/nsBidiFrames.cpp index b73ab9c2c5e..9533a9a1332 100644 --- a/mozilla/layout/generic/nsBidiFrames.cpp +++ b/mozilla/layout/generic/nsBidiFrames.cpp @@ -85,7 +85,7 @@ nsDirectionalFrame::operator new(size_t aSize) { void* frame = ::operator new(aSize); if (frame) { - nsCRT::zero(frame, aSize); + memset(frame, 0, aSize); } return frame; } diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index cc6e2066477..3d121e22091 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -250,7 +250,7 @@ nsFrame::operator new(size_t sz, nsIPresShell* aPresShell) aPresShell->AllocateFrame(sz, &result); if (result) { - nsCRT::zero(result, sz); + memset(result, 0, sz); } return result; @@ -4090,7 +4090,7 @@ NS_IMETHODIMP nsFrame::GetBidiProperty(nsIPresContext* aPresContext, return NS_ERROR_ILLEGAL_VALUE; } - nsCRT::zero(aPropertyValue, aSize); + memset(aPropertyValue, 0, aSize); void* val = nsnull; nsCOMPtr presShell; diff --git a/mozilla/layout/html/base/src/nsBidiFrames.cpp b/mozilla/layout/html/base/src/nsBidiFrames.cpp index b73ab9c2c5e..9533a9a1332 100644 --- a/mozilla/layout/html/base/src/nsBidiFrames.cpp +++ b/mozilla/layout/html/base/src/nsBidiFrames.cpp @@ -85,7 +85,7 @@ nsDirectionalFrame::operator new(size_t aSize) { void* frame = ::operator new(aSize); if (frame) { - nsCRT::zero(frame, aSize); + memset(frame, 0, aSize); } return frame; } diff --git a/mozilla/layout/html/base/src/nsFrame.cpp b/mozilla/layout/html/base/src/nsFrame.cpp index cc6e2066477..3d121e22091 100644 --- a/mozilla/layout/html/base/src/nsFrame.cpp +++ b/mozilla/layout/html/base/src/nsFrame.cpp @@ -250,7 +250,7 @@ nsFrame::operator new(size_t sz, nsIPresShell* aPresShell) aPresShell->AllocateFrame(sz, &result); if (result) { - nsCRT::zero(result, sz); + memset(result, 0, sz); } return result; @@ -4090,7 +4090,7 @@ NS_IMETHODIMP nsFrame::GetBidiProperty(nsIPresContext* aPresContext, return NS_ERROR_ILLEGAL_VALUE; } - nsCRT::zero(aPropertyValue, aSize); + memset(aPropertyValue, 0, aSize); void* val = nsnull; nsCOMPtr presShell; diff --git a/mozilla/layout/style/nsStyleStruct.cpp b/mozilla/layout/style/nsStyleStruct.cpp index 5e9b21d6a08..6bb90e8e8c7 100644 --- a/mozilla/layout/style/nsStyleStruct.cpp +++ b/mozilla/layout/style/nsStyleStruct.cpp @@ -238,7 +238,7 @@ nsStyleFont::operator new(size_t sz, nsIPresContext* aContext) { void* result = nsnull; aContext->AllocateFromShell(sz, &result); if (result) - nsCRT::zero(result, sz); + memset(result, 0, sz); return result; } @@ -319,7 +319,7 @@ nsStyleMargin::operator new(size_t sz, nsIPresContext* aContext) { void* result = nsnull; aContext->AllocateFromShell(sz, &result); if (result) - nsCRT::zero(result, sz); + memset(result, 0, sz); return result; } @@ -378,7 +378,7 @@ nsStylePadding::operator new(size_t sz, nsIPresContext* aContext) { void* result = nsnull; aContext->AllocateFromShell(sz, &result); if (result) - nsCRT::zero(result, sz); + memset(result, 0, sz); return result; } @@ -478,7 +478,7 @@ nsStyleBorder::operator new(size_t sz, nsIPresContext* aContext) { void* result = nsnull; aContext->AllocateFromShell(sz, &result); if (result) - nsCRT::zero(result, sz); + memset(result, 0, sz); return result; } diff --git a/mozilla/layout/xul/base/src/nsBoxLayoutState.cpp b/mozilla/layout/xul/base/src/nsBoxLayoutState.cpp index 3f63860b586..a4b99bf426c 100644 --- a/mozilla/layout/xul/base/src/nsBoxLayoutState.cpp +++ b/mozilla/layout/xul/base/src/nsBoxLayoutState.cpp @@ -404,7 +404,7 @@ nsBoxLayoutState::Allocate(size_t sz, nsIPresShell* aPresShell) aPresShell->AllocateFrame(sz, &result); if (result) { - nsCRT::zero(result, sz); + memset(result, 0, sz); } return result; diff --git a/mozilla/netwerk/cache/src/nsDiskCacheBlockFile.cpp b/mozilla/netwerk/cache/src/nsDiskCacheBlockFile.cpp index f34f9755748..1d6514a85b3 100644 --- a/mozilla/netwerk/cache/src/nsDiskCacheBlockFile.cpp +++ b/mozilla/netwerk/cache/src/nsDiskCacheBlockFile.cpp @@ -61,7 +61,7 @@ nsDiskCacheBlockFile::Open( nsILocalFile * blockFile, PRUint32 blockSize) mEndOfFile = fileSize; if (mEndOfFile == 0) { // initialize bit map and write it - nsCRT::zero(mBitMap, kBitMapBytes); + memset(mBitMap, 0, kBitMapBytes); PRInt32 bytesWritten = PR_Write(mFD, mBitMap, kBitMapBytes); if (bytesWritten < kBitMapBytes) goto error_exit; mEndOfFile = kBitMapBytes; diff --git a/mozilla/netwerk/cache/src/nsDiskCacheEntry.cpp b/mozilla/netwerk/cache/src/nsDiskCacheEntry.cpp index 379d0427d80..5a87aec06eb 100644 --- a/mozilla/netwerk/cache/src/nsDiskCacheEntry.cpp +++ b/mozilla/netwerk/cache/src/nsDiskCacheEntry.cpp @@ -132,7 +132,7 @@ CreateDiskCacheEntry(nsDiskCacheBinding * binding) pad -= diskEntry->Size(); NS_ASSERTION(pad >= 0, "under allocated buffer for diskEntry."); if (pad > 0) - nsCRT::zero(&diskEntry->mKeyStart[keySize+metaSize], pad); + memset(&diskEntry->mKeyStart[keySize+metaSize], 0, pad); return diskEntry; } diff --git a/mozilla/netwerk/cache/src/nsDiskCacheMap.cpp b/mozilla/netwerk/cache/src/nsDiskCacheMap.cpp index 06fda7d34ff..749c5af3bee 100644 --- a/mozilla/netwerk/cache/src/nsDiskCacheMap.cpp +++ b/mozilla/netwerk/cache/src/nsDiskCacheMap.cpp @@ -173,8 +173,8 @@ nsDiskCacheMap::Open(nsILocalFile * cacheDirectory) mHeader.mEvictionRank[i] = 0; } - nsCRT::zero(mHeader.reserved, nsDiskCacheHeader::kReservedBytes); - nsCRT::zero(mBuckets, sizeof(nsDiskCacheBucket) * kBucketsPerTable); + memset(mHeader.reserved, 0, nsDiskCacheHeader::kReservedBytes); + memset(mBuckets, 0, sizeof(nsDiskCacheBucket) * kBucketsPerTable); } else if (mapSize == kCacheMapSize) { // read it in diff --git a/mozilla/netwerk/streamconv/src/nsAppleFileDecoder.cpp b/mozilla/netwerk/streamconv/src/nsAppleFileDecoder.cpp index 601aa2271bb..74fad75385a 100644 --- a/mozilla/netwerk/streamconv/src/nsAppleFileDecoder.cpp +++ b/mozilla/netwerk/streamconv/src/nsAppleFileDecoder.cpp @@ -57,9 +57,9 @@ nsAppleFileDecoder::nsAppleFileDecoder() m_headerOk = PR_FALSE; m_comment[0] = 0; - nsCRT::zero(&m_dates, sizeof(m_dates)); - nsCRT::zero(&m_finderInfo, sizeof(m_dates)); - nsCRT::zero(&m_finderExtraInfo, sizeof(m_dates)); + memset(&m_dates, 0, sizeof(m_dates)); + memset(&m_finderInfo, 0, sizeof(m_dates)); + memset(&m_finderExtraInfo, 0, sizeof(m_dates)); } nsAppleFileDecoder::~nsAppleFileDecoder() @@ -152,13 +152,13 @@ NS_IMETHODIMP nsAppleFileDecoder::Close(void) GetVolParmsInfoBuffer vp; DTPBRec dtp; - nsCRT::zero((void *) &vinfo, sizeof (vinfo)); + memset((void *) &vinfo, 0, sizeof (vinfo)); vinfo.ioVRefNum = fpb->ioVRefNum; vinfo.ioBuffer = (Ptr) &vp; vinfo.ioReqCount = sizeof (vp); if (PBHGetVolParmsSync((HParmBlkPtr) &vinfo) == noErr && ((vp.vMAttrib >> bHasDesktopMgr) & 1)) { - nsCRT::zero((void *) &dtp, sizeof (dtp)); + memset((void *) &dtp, 0, sizeof (dtp)); dtp.ioVRefNum = fpb->ioVRefNum; if (PBDTGetPath(&dtp) == noErr) { diff --git a/mozilla/parser/htmlparser/src/nsDTDUtils.cpp b/mozilla/parser/htmlparser/src/nsDTDUtils.cpp index fa59b793200..e52d467fddf 100644 --- a/mozilla/parser/htmlparser/src/nsDTDUtils.cpp +++ b/mozilla/parser/htmlparser/src/nsDTDUtils.cpp @@ -1489,7 +1489,7 @@ NS_IMPL_ISUPPORTS1(nsObserverEntry, nsIObserverEntry) nsObserverEntry::nsObserverEntry(const nsAString& aTopic) : mTopic(aTopic) { NS_INIT_ISUPPORTS(); - nsCRT::zero(mObservers,sizeof(mObservers)); + memset(mObservers, 0, sizeof(mObservers)); } nsObserverEntry::~nsObserverEntry() { diff --git a/mozilla/uriloader/exthandler/mac/nsDecodeAppleFile.cpp b/mozilla/uriloader/exthandler/mac/nsDecodeAppleFile.cpp index 1aa4877c3c0..fa8f54403f5 100644 --- a/mozilla/uriloader/exthandler/mac/nsDecodeAppleFile.cpp +++ b/mozilla/uriloader/exthandler/mac/nsDecodeAppleFile.cpp @@ -63,9 +63,9 @@ nsDecodeAppleFile::nsDecodeAppleFile() m_headerOk = PR_FALSE; m_comment[0] = 0; - nsCRT::zero(&m_dates, sizeof(m_dates)); - nsCRT::zero(&m_finderInfo, sizeof(m_dates)); - nsCRT::zero(&m_finderExtraInfo, sizeof(m_dates)); + memset(&m_dates, 0, sizeof(m_dates)); + memset(&m_finderInfo, 0, sizeof(m_dates)); + memset(&m_finderExtraInfo, 0, sizeof(m_dates)); } nsDecodeAppleFile::~nsDecodeAppleFile() @@ -152,13 +152,13 @@ NS_IMETHODIMP nsDecodeAppleFile::Close(void) GetVolParmsInfoBuffer vp; DTPBRec dtp; - nsCRT::zero((void *) &vinfo, sizeof (vinfo)); + memset((void *) &vinfo, 0, sizeof (vinfo)); vinfo.ioVRefNum = fpb->ioVRefNum; vinfo.ioBuffer = (Ptr) &vp; vinfo.ioReqCount = sizeof (vp); if (PBHGetVolParmsSync((HParmBlkPtr) &vinfo) == noErr && ((vp.vMAttrib >> bHasDesktopMgr) & 1)) { - nsCRT::zero((void *) &dtp, sizeof (dtp)); + memset((void *) &dtp, 0, sizeof (dtp)); dtp.ioVRefNum = fpb->ioVRefNum; if (PBDTGetPath(&dtp) == noErr) { diff --git a/mozilla/xpcom/ds/nsCRT.h b/mozilla/xpcom/ds/nsCRT.h index d3d4eabce9d..c1178c95f52 100644 --- a/mozilla/xpcom/ds/nsCRT.h +++ b/mozilla/xpcom/ds/nsCRT.h @@ -67,7 +67,7 @@ extern const PRUnichar kIsoLatin1ToUCS2[256]; void* operator new(size_t sz) { \ void* rv = ::operator new(sz); \ if (rv) { \ - nsCRT::zero(rv, sz); \ + memset(rv, 0, sz); \ } \ return rv; \ } \ @@ -85,7 +85,7 @@ extern const PRUnichar kIsoLatin1ToUCS2[256]; void* _class::operator new(size_t sz) { \ void* rv = ::operator new(sz); \ if (rv) { \ - nsCRT::zero(rv, sz); \ + memset(rv, 0, sz); \ } \ return rv; \ } \ @@ -134,10 +134,10 @@ public: ::memset(aDest, aByte, aCount); } - static void zero(void* aDest, PRUint32 aCount) { - NS_ASSERTION((aDest != NULL) || (aCount == 0), "Invalid NULL argument"); - ::memset(aDest, 0, (size_t)aCount); - } + /**** + **** nsCRT::zero() is no longer supported. + **** Please use memset from standard C instead. + ****/ /** Compute the string length of s @param s the string in question diff --git a/mozilla/xpcom/ds/nsDeque.cpp b/mozilla/xpcom/ds/nsDeque.cpp index 4c889b59fbc..e3f5d70c391 100644 --- a/mozilla/xpcom/ds/nsDeque.cpp +++ b/mozilla/xpcom/ds/nsDeque.cpp @@ -56,7 +56,7 @@ nsDeque::nsDeque(nsDequeFunctor* aDeallocator) { mOrigin=mSize=0; mData=mBuffer; // don't allocate space until you must mCapacity=sizeof(mBuffer)/sizeof(mBuffer[0]); - nsCRT::zero(mData,mCapacity*sizeof(mBuffer[0])); + memset(mData, 0, mCapacity*sizeof(mBuffer[0])); } @@ -122,7 +122,7 @@ void nsDeque::SetDeallocator(nsDequeFunctor* aDeallocator){ */ nsDeque& nsDeque::Empty() { if((0