Revision: 2739
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2739&view=rev
Author:   rorthomas
Date:     2012-05-28 18:11:05 +0000 (Mon, 28 May 2012)
Log Message:
-----------
fixed globals dir
added zeroedmemoryallocator

Modified Paths:
--------------
    trunk/CMakeMacros.txt
    trunk/source/main/CMakeLists.txt
    trunk/source/main/RoRPrerequisites.h
    trunk/source/main/gameplay/RoRFrameListener.h

Added Paths:
-----------
    trunk/source/main/utils/ZeroedMemoryAllocator.h

Modified: trunk/CMakeMacros.txt
===================================================================
--- trunk/CMakeMacros.txt       2012-05-28 16:03:50 UTC (rev 2738)
+++ trunk/CMakeMacros.txt       2012-05-28 18:11:05 UTC (rev 2739)
@@ -60,3 +60,10 @@
        set(${BINNAME}_headers ${${BINNAME}_headers} 
${${BINNAME}_${name}_header})
 endmacro(add_sub_dir)
 
+macro(add_main_dir BINNAME)
+       FILE(GLOB ${BINNAME}_main_source ${RoR_Main_SOURCE_DIR}/*.cpp 
${RoR_Main_SOURCE_DIR}/*.c)
+       FILE(GLOB ${BINNAME}_main_header ${RoR_Main_SOURCE_DIR}/*.h)
+       SOURCE_GROUP("globals" FILES ${${BINNAME}_main_source} 
${${BINNAME}_main_header})
+       set(${BINNAME}_sources ${${BINNAME}_sources} ${${BINNAME}_main_source})
+       set(${BINNAME}_headers ${${BINNAME}_headers} ${${BINNAME}_main_header})
+endmacro(add_main_dir)

Modified: trunk/source/main/CMakeLists.txt
===================================================================
--- trunk/source/main/CMakeLists.txt    2012-05-28 16:03:50 UTC (rev 2738)
+++ trunk/source/main/CMakeLists.txt    2012-05-28 18:11:05 UTC (rev 2739)
@@ -101,10 +101,8 @@
   add_sub_dir(${BINNAME} sqlite)
   add_sub_dir(${BINNAME} framework)
   add_sub_dir(${BINNAME} ${folder})
+  add_main_dir(${BINNAME})
   
-  set(${BINNAME}_headers ${${BINNAME}_headers} 
${RoR_Main_SOURCE_DIR}/RoRPrerequisites.h ${RoR_Main_SOURCE_DIR}/RoRVersion.h)
-  SOURCE_GROUP("globals" FILES ${RoR_Main_SOURCE_DIR}/RoRPrerequisites.h 
${RoR_Main_SOURCE_DIR}/RoRVersion.h)
-
   if(${useWxWidgets})
     # find wxWidgets
     SET(wxWidgets_USE_UNICODE ON)

Modified: trunk/source/main/RoRPrerequisites.h
===================================================================
--- trunk/source/main/RoRPrerequisites.h        2012-05-28 16:03:50 UTC (rev 
2738)
+++ trunk/source/main/RoRPrerequisites.h        2012-05-28 18:11:05 UTC (rev 
2739)
@@ -40,6 +40,7 @@
 #include <OgreUTFString.h>
 
 #include "GlobalEnvironment.h"
+#include "ZeroedMemoryAllocator.h" // this is used quite a lot, so we include 
it here already
 
 // some config for angelscript, doesnt matter if we compile with angelscript 
or not as its just a definition
 #ifdef USE_ANGELSCRIPT

Modified: trunk/source/main/gameplay/RoRFrameListener.h
===================================================================
--- trunk/source/main/gameplay/RoRFrameListener.h       2012-05-28 16:03:50 UTC 
(rev 2738)
+++ trunk/source/main/gameplay/RoRFrameListener.h       2012-05-28 18:11:05 UTC 
(rev 2739)
@@ -50,7 +50,7 @@
 }
 #endif //USE_PAGED
 
-class RoRFrameListener: public Ogre::FrameListener, public 
Ogre::WindowEventListener
+class RoRFrameListener: public Ogre::FrameListener, public 
Ogre::WindowEventListener, public ZeroedMemoryAllocator
 {
 public:
        // Constructor takes a RenderWindow because it uses that to determine 
input context

Added: trunk/source/main/utils/ZeroedMemoryAllocator.h
===================================================================
--- trunk/source/main/utils/ZeroedMemoryAllocator.h                             
(rev 0)
+++ trunk/source/main/utils/ZeroedMemoryAllocator.h     2012-05-28 18:11:05 UTC 
(rev 2739)
@@ -0,0 +1,81 @@
+/*
+This source file is part of Rigs of Rods
+Copyright 2005-2012 Pierre-Michel Ricordel
+Copyright 2007-2012 Thomas Fischer
+
+For more information, see http://www.rigsofrods.com/
+
+Rigs of Rods is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License version 3, as
+published by the Free Software Foundation.
+
+Rigs of Rods is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Rigs of Rods.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+// based on the openttd class of the same name
+// this helps finding problems when uninitialized member pointers are used
+
+#ifndef ZEROMEMORYALLOCATOR_H__
+#define ZEROMEMORYALLOCATOR_H__
+
+/**
+ * Base class that provides memory initialization on dynamically created 
objects.
+ * All allocated memory will be zeroed.
+ */
+class ZeroedMemoryAllocator
+{
+public:
+       ZeroedMemoryAllocator()
+       {
+       }
+       
+       virtual ~ZeroedMemoryAllocator()
+       {
+       }
+
+       /**
+        * Memory allocator for a single class instance.
+        * @param size the amount of bytes to allocate.
+        * @return the given amounts of bytes zeroed.
+        */
+       inline void *operator new(size_t size)
+       {
+               return calloc(size, sizeof(char));
+       }
+
+       /**
+        * Memory allocator for an array of class instances.
+        * @param size the amount of bytes to allocate.
+        * @return the given amounts of bytes zeroed.
+        */
+       inline void *operator new[](size_t size)
+       {
+               return calloc(size, sizeof(char));
+       }
+
+       /**
+        * Memory release for a single class instance.
+        * @param ptr  the memory to free.
+        */
+       inline void operator delete(void *ptr)
+       {
+               free(ptr);
+       }
+
+       /**
+        * Memory release for an array of class instances.
+        * @param ptr  the memory to free.
+        */
+       inline void operator delete[](void *ptr)
+       {
+               free(ptr);
+       }
+};
+
+#endif // ZEROMEMORYALLOCATOR_H__

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Rigsofrods-devel mailing list
Rigsofrods-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel

Reply via email to