X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Futil%2Fpointer.h;h=7f6654787814527f2c38e715a2e8f1f9744e7724;hb=984e063374c032ed17764931fd00c19afb92ebb9;hp=96f4c656b6372cff6c0b08e8f2a03d19ba2e0aa2;hpb=497ff1ecd64c8908f988e15ca879824f2781e3fd;p=oweals%2Fminetest.git diff --git a/src/util/pointer.h b/src/util/pointer.h index 96f4c656b..7f6654787 100644 --- a/src/util/pointer.h +++ b/src/util/pointer.h @@ -1,6 +1,6 @@ /* Minetest -Copyright (C) 2010-2012 celeron55, Perttu Ahola +Copyright (C) 2010-2013 celeron55, Perttu Ahola 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 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