From c4aee0da6255c147f97ef42ac1295d5aa89d02c4 Mon Sep 17 00:00:00 2001 From: "waterson%netscape.com" Date: Thu, 4 Feb 1999 00:25:56 +0000 Subject: [PATCH] Added operator new() and operator delete() to ensure that nobody tries to create one of these beasts on the free store. git-svn-id: svn://10.0.0.236/trunk@19612 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/base/public/nsAutoLock.h | 15 +++++++++++++-- mozilla/xpcom/threads/nsAutoLock.h | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/mozilla/base/public/nsAutoLock.h b/mozilla/base/public/nsAutoLock.h index 195c710ec1b..44fc7567db2 100644 --- a/mozilla/base/public/nsAutoLock.h +++ b/mozilla/base/public/nsAutoLock.h @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * The contents of this file are subject to the Netscape Public License * Version 1.0 (the "NPL"); you may not use this file except in @@ -79,9 +79,20 @@ class nsAutoLock { private: PRLock* mLock; - // XXX not allowed + // Not meant to be implemented. This makes it a compiler error to + // construct or assign an nsAutoLock object incorrectly. nsAutoLock(void) {} nsAutoLock(nsAutoLock& aLock) {} + nsAutoLock& operator =(nsAutoLock& aLock) { + return *this; + } + + // Not meant to be implemented. This makes it a compiler error to + // attempt to create an nsAutoLock object on the heap. + static void* operator new(size_t size) { + return nsnull; + } + static void operator delete(void* memory) {} public: nsAutoLock(PRLock* aLock) : mLock(aLock) { diff --git a/mozilla/xpcom/threads/nsAutoLock.h b/mozilla/xpcom/threads/nsAutoLock.h index 195c710ec1b..44fc7567db2 100644 --- a/mozilla/xpcom/threads/nsAutoLock.h +++ b/mozilla/xpcom/threads/nsAutoLock.h @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * The contents of this file are subject to the Netscape Public License * Version 1.0 (the "NPL"); you may not use this file except in @@ -79,9 +79,20 @@ class nsAutoLock { private: PRLock* mLock; - // XXX not allowed + // Not meant to be implemented. This makes it a compiler error to + // construct or assign an nsAutoLock object incorrectly. nsAutoLock(void) {} nsAutoLock(nsAutoLock& aLock) {} + nsAutoLock& operator =(nsAutoLock& aLock) { + return *this; + } + + // Not meant to be implemented. This makes it a compiler error to + // attempt to create an nsAutoLock object on the heap. + static void* operator new(size_t size) { + return nsnull; + } + static void operator delete(void* memory) {} public: nsAutoLock(PRLock* aLock) : mLock(aLock) {