Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:15:14

0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  * 
0009  *      http://www.apache.org/licenses/LICENSE-2.0
0010  * 
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 /*
0019  * $Id$
0020  */
0021 
0022 #if !defined(XERCESC_INCLUDE_GUARD_XMEMORY_HPP)
0023 #define XERCESC_INCLUDE_GUARD_XMEMORY_HPP
0024 
0025 #include <xercesc/util/XercesDefs.hpp>
0026 #include <stdlib.h>
0027 
0028 XERCES_CPP_NAMESPACE_BEGIN
0029 
0030 class MemoryManager;
0031 
0032 /**
0033  *  This class makes it possible to override the C++ memory management by
0034  *  adding new/delete operators to this base class.
0035  *
0036  *  This class is used in conjunction with the pluggable memory manager. It
0037  *  allows applications to control Xerces memory management.
0038  */
0039 
0040 class XMLUTIL_EXPORT XMemory
0041 {
0042 public :
0043     // -----------------------------------------------------------------------
0044     //  The C++ memory management
0045     // -----------------------------------------------------------------------
0046     /** @name The C++ memory management */
0047     //@{
0048 
0049     /**
0050       * This method overrides operator new
0051       *
0052       * @param size The requested memory size
0053       */
0054     void* operator new(size_t size);
0055 
0056 #if defined(XERCES_MFC_SUPPORT)
0057     /**
0058       * This method overrides the MFC debug version of the operator new
0059       * 
0060       * @param size   The requested memory size
0061       * @param file   The file where the allocation was requested
0062       * @param line   The line where the allocation was requested 
0063       */ 
0064     void* operator new(size_t size, const char* file, int line);
0065     /**
0066       * This method provides a matching delete for the MFC debug new
0067       * 
0068       * @param p      The pointer to the allocated memory
0069       * @param file   The file where the allocation was requested
0070       * @param line   The line where the allocation was requested 
0071       */ 
0072     void operator delete(void* p, const char* file, int line);
0073 #endif
0074 
0075     /**
0076       * This method defines a custom operator new, that will use the provided
0077       * memory manager to perform the allocation
0078       *
0079       * @param size   The requested memory size
0080       * @param memMgr An application's memory manager
0081       */
0082     void* operator new(size_t size, MemoryManager* memMgr);
0083 
0084     /**
0085       * This method overrides placement operator new
0086       *
0087       * @param size   The requested memory size
0088       * @param ptr    The memory location where the object should be allocated
0089       */
0090     void* operator new(size_t size, void* ptr);
0091 
0092     /**
0093       * This method overrides operator delete
0094       *
0095       * @param p The pointer to the allocated memory
0096       */
0097     void operator delete(void* p);
0098 
0099      //The Borland compiler is complaining about duplicate overloading of delete
0100 #if !defined(XERCES_NO_MATCHING_DELETE_OPERATOR)
0101     /**
0102       * This method provides a matching delete for the custom operator new
0103       *
0104       * @param p      The pointer to the allocated memory
0105       * @param memMgr An application's memory manager 
0106       */
0107     void operator delete(void* p, MemoryManager* memMgr);
0108 
0109     /**
0110       * This method provides a matching delete for the placement new
0111       *
0112       * @param p      The pointer to the allocated memory
0113       * @param ptr    The memory location where the object had to be allocated
0114       */
0115     void operator delete(void* p, void* ptr);
0116 #endif
0117 
0118     //@}
0119 
0120 protected :
0121     // -----------------------------------------------------------------------
0122     //  Hidden Constructors
0123     // -----------------------------------------------------------------------
0124     /** @name Constructor */
0125     //@{
0126 
0127     /**
0128       * Protected default constructor
0129       */
0130     XMemory()
0131     {
0132     }
0133     //@}
0134 
0135 #if defined(XERCES_NEED_XMEMORY_VIRTUAL_DESTRUCTOR)
0136     virtual ~XMemory()
0137     {
0138     }
0139 #endif
0140 };
0141 
0142 XERCES_CPP_NAMESPACE_END
0143 
0144 #endif