source: OGRE/trunk/ogrenew/OgreMain/include/OgreMemoryMacros.h @ 657

Revision 657, 3.7 KB checked in by mattausch, 19 years ago (diff)

added ogre dependencies and patched ogre sources

Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25//---- ORIGINAL COPYRIGHT FOLLOWS -------------------------------------------
26// ---------------------------------------------------------------------------------------------------------------------------------
27// Copyright 2000, Paul Nettle. All rights reserved.
28//
29// You are free to use this source code in any commercial or non-commercial product.
30//
31// mmgr.cpp - Memory manager & tracking software
32//
33// The most recent version of this software can be found at: ftp://ftp.GraphicsPapers.com/pub/ProgrammingTools/MemoryManagers/
34//
35// [NOTE: Best when viewed with 8-character tabs]
36//
37// ---------------------------------------------------------------------------------------------------------------------------------
38
39//-----------------------------------------------------------------------------
40// How does this work?
41// Remember that before the compiler starts to process a source file, it runs
42// a neat tool called a preprocessor on it. What this preprocessor does in
43// this case is replace all the instances of *alloc/free with the expanded
44// macros - this way we cleverly replace all the calls to the standard C
45// memory (de)allocation functions. The same is done for new/delete
46//
47// Of course, we have the drawback that we can't name a member function of
48// a class *alloc or free and we can't overload the new/delete operators without
49// first undefining these macros - ah, a C++ preprocessor with RE replacement,
50// that would be a dream come true :)
51//
52#ifndef OGRE_MEMORY_MACROS
53#define OGRE_MEMORY_MACROS
54
55#if OGRE_DEBUG_MEMORY_MANAGER && OGRE_DEBUG_MODE
56#   define new    (::Ogre::MemoryManager::instance().setOwner(__FILE__,__LINE__,__FUNCTION__),false) ? NULL                                                 : new
57#   define delete (::Ogre::MemoryManager::instance().setOwner(__FILE__,__LINE__,__FUNCTION__),false) ? ::Ogre::MemoryManager::instance().setOwner("",0,"") : delete
58#   define malloc(sz)      ::Ogre::MemoryManager::instance().allocMem(__FILE__,__LINE__,__FUNCTION__, ::Ogre::m_alloc_malloc, sz,      gProcessID)
59#   define calloc(sz)      ::Ogre::MemoryManager::instance().allocMem(__FILE__,__LINE__,__FUNCTION__, ::Ogre::m_alloc_calloc, sz,      gProcessID)
60#   define realloc(ptr,sz) ::Ogre::MemoryManager::instance().rllocMem(__FILE__,__LINE__,__FUNCTION__, ::Ogre::m_alloc_realloc,sz, ptr, gProcessID)
61#   define free(ptr)       ::Ogre::MemoryManager::instance().dllocMem(__FILE__,__LINE__,__FUNCTION__, ::Ogre::m_alloc_free,       ptr, gProcessID)
62#endif // OGRE_DEBUG_MEMORY_MANAGER
63
64#endif // OGRE_MEMORY_MACROS
65//-----------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.