Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/OgreMain/include/OgreMemoryMacros.h @ 5

Last change on this file since 5 was 5, checked in by anonymous, 17 years ago

=hoffentlich gehts jetzt

File size: 3.9 KB
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-2006 Torus Knot Software Ltd
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
24You may alternatively use this source under the terms of a specific version of
25the OGRE Unrestricted License provided you have obtained such a license from
26Torus Knot Software Ltd.
27-----------------------------------------------------------------------------
28*/
29//---- ORIGINAL COPYRIGHT FOLLOWS -------------------------------------------
30// ---------------------------------------------------------------------------------------------------------------------------------
31// Copyright 2000, Paul Nettle. All rights reserved.
32//
33// You are free to use this source code in any commercial or non-commercial product.
34//
35// mmgr.cpp - Memory manager & tracking software
36//
37// The most recent version of this software can be found at: ftp://ftp.GraphicsPapers.com/pub/ProgrammingTools/MemoryManagers/
38//
39// [NOTE: Best when viewed with 8-character tabs]
40//
41// ---------------------------------------------------------------------------------------------------------------------------------
42
43//-----------------------------------------------------------------------------
44// How does this work?
45// Remember that before the compiler starts to process a source file, it runs
46// a neat tool called a preprocessor on it. What this preprocessor does in
47// this case is replace all the instances of *alloc/free with the expanded
48// macros - this way we cleverly replace all the calls to the standard C
49// memory (de)allocation functions. The same is done for new/delete
50//
51// Of course, we have the drawback that we can't name a member function of
52// a class *alloc or free and we can't overload the new/delete operators without
53// first undefining these macros - ah, a C++ preprocessor with RE replacement,
54// that would be a dream come true :)
55//
56#ifndef OGRE_MEMORY_MACROS
57#define OGRE_MEMORY_MACROS
58
59#if OGRE_DEBUG_MEMORY_MANAGER && OGRE_DEBUG_MODE
60#   define new    (::Ogre::MemoryManager::instance().setOwner(__FILE__,__LINE__,__FUNCTION__),false) ? NULL                                                 : new
61#   define delete (::Ogre::MemoryManager::instance().setOwner(__FILE__,__LINE__,__FUNCTION__),false) ? ::Ogre::MemoryManager::instance().setOwner("",0,"") : delete
62#   define malloc(sz)      ::Ogre::MemoryManager::instance().allocMem(__FILE__,__LINE__,__FUNCTION__, ::Ogre::m_alloc_malloc, sz,      gProcessID)
63#   define calloc(num,sz)  ::Ogre::MemoryManager::instance().allocMem(__FILE__,__LINE__,__FUNCTION__, ::Ogre::m_alloc_calloc, num*sz,  gProcessID)
64#   define realloc(ptr,sz) ::Ogre::MemoryManager::instance().rllocMem(__FILE__,__LINE__,__FUNCTION__, ::Ogre::m_alloc_realloc,sz, ptr, gProcessID)
65#   define free(ptr)       ::Ogre::MemoryManager::instance().dllocMem(__FILE__,__LINE__,__FUNCTION__, ::Ogre::m_alloc_free,       ptr, gProcessID)
66#endif // OGRE_DEBUG_MEMORY_MANAGER
67
68#endif // OGRE_MEMORY_MACROS
69//-----------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.