Footsteps: Fix offset footstep and shallow water sound bugs
[oweals/minetest.git] / src / util / pointer.h
index 96f4c656b6372cff6c0b08e8f2a03d19ba2e0aa2..7f6654787814527f2c38e715a2e8f1f9744e7724 100644 (file)
@@ -1,6 +1,6 @@
 /*
 Minetest
-Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
+Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU Lesser General Public License as published by
@@ -178,6 +178,14 @@ private:
        unsigned int m_size;
 };
 
+/************************************************
+ *           !!!  W A R N I N G  !!!            *
+ *           !!!  A C H T U N G  !!!            *
+ *                                              *
+ * This smart pointer class is NOT thread safe. *
+ * ONLY use in a single-threaded context!       *
+ *                                              *
+ ************************************************/
 template <typename T>
 class SharedBuffer
 {
@@ -197,6 +205,7 @@ public:
                else
                        data = NULL;
                refcount = new unsigned int;
+               memset(data,0,sizeof(T)*m_size);
                (*refcount) = 1;
        }
        SharedBuffer(const SharedBuffer &buffer)
@@ -257,7 +266,7 @@ public:
        }
        T & operator[](unsigned int i) const
        {
-               //assert(i < m_size)
+               assert(i < m_size);
                return data[i];
        }
        T * operator*() const