1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #include "salhelper/simplereferenceobject.hxx"
25 #include "osl/diagnose.h"
26
27 #ifndef INCLUDED_NEW
28 #include <new>
29 #define INCLUDED_NEW
30 #endif
31
32 using salhelper::SimpleReferenceObject;
33
~SimpleReferenceObject()34 SimpleReferenceObject::~SimpleReferenceObject() SAL_THROW(())
35 {
36 OSL_ASSERT(m_nCount == 0);
37 }
38
operator new(std::size_t nSize)39 void * SimpleReferenceObject::operator new(std::size_t nSize)
40 SAL_THROW((std::bad_alloc))
41 {
42 return ::operator new(nSize);
43 }
44
operator new(std::size_t nSize,std::nothrow_t const &)45 void * SimpleReferenceObject::operator new(std::size_t nSize,
46 std::nothrow_t const &)
47 SAL_THROW(())
48 {
49 #if defined WNT
50 return ::operator new(nSize);
51 // WNT lacks a global nothrow operator new...
52 #else // WNT
53 return ::operator new(nSize, std::nothrow);
54 #endif // WNT
55 }
56
operator delete(void * pPtr)57 void SimpleReferenceObject::operator delete(void * pPtr) SAL_THROW(())
58 {
59 ::operator delete(pPtr);
60 }
61
operator delete(void * pPtr,std::nothrow_t const &)62 void SimpleReferenceObject::operator delete(void * pPtr, std::nothrow_t const &)
63 SAL_THROW(())
64 {
65 #if defined WNT
66 ::operator delete(pPtr); // WNT lacks a global nothrow operator delete...
67 #else // WNT
68 ::operator delete(pPtr, std::nothrow);
69 #endif // WNT
70 }
71