From f58eac9104103d7b0b603208e7eefa980eff924f Mon Sep 17 00:00:00 2001 From: "kipp%netscape.com" Date: Fri, 26 Feb 1999 17:05:20 +0000 Subject: [PATCH] Implement operator delete; get rid of static constructor git-svn-id: svn://10.0.0.236/trunk@22130 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsFrame.cpp | 17 +++++++++++++---- mozilla/layout/generic/nsFrame.h | 2 ++ mozilla/layout/html/base/src/nsFrame.cpp | 17 +++++++++++++---- mozilla/layout/html/base/src/nsFrame.h | 2 ++ 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index 3366bd42f2a..5247c0a5c49 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -102,7 +102,7 @@ NS_LAYOUT PRBool nsIFrame::GetShowFrameBorders() * Note: the log module is created during library initialization which * means that you cannot perform logging before then. */ -PRLogModuleInfo* nsIFrame::gLogModule = PR_NewLogModule("frame"); +static PRLogModuleInfo* gLogModule; static PRLogModuleInfo* gFrameVerifyTreeLogModuleInfo; @@ -133,6 +133,9 @@ nsIFrame::SetVerifyTreeEnable(PRBool aEnabled) NS_LAYOUT PRLogModuleInfo* nsIFrame::GetLogModuleInfo() { + if (nsnull == gLogModule) { + gLogModule = PR_NewLogModule("frame"); + } return gLogModule; } @@ -158,12 +161,18 @@ NS_NewEmptyFrame(nsIFrame** aInstancePtrResult) void* nsFrame::operator new(size_t size) { - void* result = new char[size]; - - nsCRT::zero(result, size); + void* result = ::operator new(size); + if (result) { + nsCRT::zero(result, size); + } return result; } +void nsFrame::operator delete(void* ptr, size_t size) +{ + ::operator delete(ptr); +} + nsFrame::nsFrame() { mState = NS_FRAME_FIRST_REFLOW | NS_FRAME_SYNC_FRAME_AND_VIEW; diff --git a/mozilla/layout/generic/nsFrame.h b/mozilla/layout/generic/nsFrame.h index 94bfb5ccbe4..c7dac5b0b6a 100644 --- a/mozilla/layout/generic/nsFrame.h +++ b/mozilla/layout/generic/nsFrame.h @@ -106,6 +106,8 @@ public: // Overloaded new operator. Initializes the memory to 0 void* operator new(size_t size); + void operator delete(void* ptr, size_t size); + // nsISupports NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); diff --git a/mozilla/layout/html/base/src/nsFrame.cpp b/mozilla/layout/html/base/src/nsFrame.cpp index 3366bd42f2a..5247c0a5c49 100644 --- a/mozilla/layout/html/base/src/nsFrame.cpp +++ b/mozilla/layout/html/base/src/nsFrame.cpp @@ -102,7 +102,7 @@ NS_LAYOUT PRBool nsIFrame::GetShowFrameBorders() * Note: the log module is created during library initialization which * means that you cannot perform logging before then. */ -PRLogModuleInfo* nsIFrame::gLogModule = PR_NewLogModule("frame"); +static PRLogModuleInfo* gLogModule; static PRLogModuleInfo* gFrameVerifyTreeLogModuleInfo; @@ -133,6 +133,9 @@ nsIFrame::SetVerifyTreeEnable(PRBool aEnabled) NS_LAYOUT PRLogModuleInfo* nsIFrame::GetLogModuleInfo() { + if (nsnull == gLogModule) { + gLogModule = PR_NewLogModule("frame"); + } return gLogModule; } @@ -158,12 +161,18 @@ NS_NewEmptyFrame(nsIFrame** aInstancePtrResult) void* nsFrame::operator new(size_t size) { - void* result = new char[size]; - - nsCRT::zero(result, size); + void* result = ::operator new(size); + if (result) { + nsCRT::zero(result, size); + } return result; } +void nsFrame::operator delete(void* ptr, size_t size) +{ + ::operator delete(ptr); +} + nsFrame::nsFrame() { mState = NS_FRAME_FIRST_REFLOW | NS_FRAME_SYNC_FRAME_AND_VIEW; diff --git a/mozilla/layout/html/base/src/nsFrame.h b/mozilla/layout/html/base/src/nsFrame.h index 94bfb5ccbe4..c7dac5b0b6a 100644 --- a/mozilla/layout/html/base/src/nsFrame.h +++ b/mozilla/layout/html/base/src/nsFrame.h @@ -106,6 +106,8 @@ public: // Overloaded new operator. Initializes the memory to 0 void* operator new(size_t size); + void operator delete(void* ptr, size_t size); + // nsISupports NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);