From Neil Groves,

"I have taken the liberty of updating a few files so that there is no longer any derivation from std::vector. I have done this by adding a new file osg/MixinVector and by updating only two others: osg/PrimitiveSet and osg/Array. You will notice that this actually removes what is acknowledged as a \u2018hack\u2019 in osg/PrimitiveSet.

With the original code I did manage to find memory leaks with some compiler options on VC 8 and 9, as well as Intel compiler. I determined the leak existence by instrumenting the destructor code, and by use of a garbage collector as a leak detector (in a similar manner to the Firefox project). Hence in contrast to what I said originally, it is exhibiting symptoms on at least some platforms.

Since I am trying to be a good OSG citizen I got out my editor and started hacking! I have built and tested on Linux (Ubuntu) with GCC 4.x and Windows VC 8 SP1. It appears that nothing is broken, and that I\u2019m using less memory J"
This commit is contained in:
Robert Osfield
2008-06-19 20:38:38 +00:00
parent d6469b87c1
commit 2011028ee7
3 changed files with 229 additions and 66 deletions

View File

@@ -23,6 +23,7 @@
#include <osg/Vec2d>
#include <osg/Vec3d>
#include <osg/Vec4d>
#include <osg/MixinVector>
#include <osg/BufferObject>
@@ -30,59 +31,10 @@
namespace osg {
// ******************************** HACK **********************************
// Following classes are needed by VC++ in order to avoid linking errors due
// to multiply defined member functions. Classes that would normally derive
// from std::vector<T> (and that are exported via OSG_EXPORT) should derive
// from one of these classes instead.
//
// NOTE: to keep the interface consistent and avoid breaking introspection
// wrappers, this hack was deliberately made not Microsoft-specific
// even though other compilers like GCC actually don't need that.
//
// Marco Jez, Dec 2005
class VectorGLsizei: public std::vector<GLsizei>
{
typedef std::vector<value_type> vector_type;
public:
VectorGLsizei(): vector_type() {}
VectorGLsizei(const VectorGLsizei &copy): vector_type(copy) {}
VectorGLsizei(GLsizei* beg, GLsizei* end): vector_type(beg, end) {}
explicit VectorGLsizei(unsigned int n): vector_type(n) {}
};
class VectorGLubyte: public std::vector<GLubyte>
{
typedef std::vector<value_type> vector_type;
public:
VectorGLubyte(): vector_type() {}
VectorGLubyte(const VectorGLubyte &copy): vector_type(copy) {}
VectorGLubyte(const GLubyte* beg, const GLubyte* end): vector_type(beg, end) {}
explicit VectorGLubyte(unsigned int n): vector_type(n) {}
};
class VectorGLushort: public std::vector<GLushort>
{
typedef std::vector<value_type> vector_type;
public:
VectorGLushort(): vector_type() {}
VectorGLushort(const VectorGLushort &copy): vector_type(copy) {}
VectorGLushort(const GLushort* beg, const GLushort* end): vector_type(beg, end) {}
explicit VectorGLushort(unsigned int n): vector_type(n) {}
};
class VectorGLuint: public std::vector<GLuint>
{
typedef std::vector<value_type> vector_type;
public:
VectorGLuint(): vector_type() {}
VectorGLuint(const VectorGLuint &copy): vector_type(copy) {}
VectorGLuint(const GLuint* beg, const GLuint* end): vector_type(beg, end) {}
explicit VectorGLuint(unsigned int n): vector_type(n) {}
};
// **************************************************************************
typedef MixinVector<GLsizei> VectorGLsizei;
typedef MixinVector<GLubyte> VectorGLubyte;
typedef MixinVector<GLushort> VectorGLushort;
typedef MixinVector<GLuint> VectorGLuint;
class State;