kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #24402
[PATCH 3/3] Replace last instance of boost::shared_array
This is a bit tricky, because the smart pointer is actually used only for
delayed deletion, and no users of the object are involved.
This code could probably be replaced with a pool allocator that flushes the
entire pool after rendering is complete, to improve performance.
---
common/gal/opengl/opengl_gal.cpp | 10 +++++-----
include/gal/opengl/opengl_gal.h | 5 ++---
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp
index 330e390..7729d0c 100644
--- a/common/gal/opengl/opengl_gal.cpp
+++ b/common/gal/opengl/opengl_gal.cpp
@@ -1167,15 +1167,15 @@ void CALLBACK CombineCallback( GLdouble coords[3],
GLdouble* vertex_data[4],
GLfloat weight[4], GLdouble** dataOut, void* aData )
{
- GLdouble* vertex = new GLdouble[3];
+ std::unique_ptr<GLdouble[]> vertex( new GLdouble[3] );
OPENGL_GAL::TessParams* param = static_cast<OPENGL_GAL::TessParams*>( aData );
- // Save the pointer so we can delete it later
- param->intersectPoints.push_back( boost::shared_array<GLdouble>( vertex ) );
+ memcpy( vertex.get(), coords, 3 * sizeof(GLdouble) );
- memcpy( vertex, coords, 3 * sizeof(GLdouble) );
+ *dataOut = vertex.get();
- *dataOut = vertex;
+ // Save the pointer so we can delete it later
+ param->intersectPoints.emplace_back( std::move( vertex ) );
}
diff --git a/include/gal/opengl/opengl_gal.h b/include/gal/opengl/opengl_gal.h
index 37ec5d8..42be14a 100644
--- a/include/gal/opengl/opengl_gal.h
+++ b/include/gal/opengl/opengl_gal.h
@@ -40,7 +40,6 @@
#include <wx/glcanvas.h>
#include <map>
-#include <boost/smart_ptr/shared_array.hpp>
#include <memory>
#ifndef CALLBACK
@@ -244,7 +243,7 @@ public:
VERTEX_MANAGER* vboManager;
/// Intersect points, that have to be freed after tessellation
- std::deque< boost::shared_array<GLdouble> >& intersectPoints;
+ std::deque< std::unique_ptr<GLdouble[]> >& intersectPoints;
} TessParams;
protected:
@@ -288,7 +287,7 @@ private:
/// The tessellator
GLUtesselator* tesselator;
/// Storage for intersecting points
- std::deque< boost::shared_array<GLdouble> > tessIntersects;
+ std::deque< std::unique_ptr<GLdouble[]> > tessIntersects;
/**
* @brief Draw a quad for the line.
References