|
From: <md...@us...> - 2008-02-19 21:33:29
|
Revision: 4983
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4983&view=rev
Author: mdboom
Date: 2008-02-19 13:33:26 -0800 (Tue, 19 Feb 2008)
Log Message:
-----------
Fix memory leaks and uninitialized memory errors discovered with valgrind.
Modified Paths:
--------------
trunk/matplotlib/src/_path.cpp
Modified: trunk/matplotlib/src/_path.cpp
===================================================================
--- trunk/matplotlib/src/_path.cpp 2008-02-19 21:32:48 UTC (rev 4982)
+++ trunk/matplotlib/src/_path.cpp 2008-02-19 21:33:26 UTC (rev 4983)
@@ -309,6 +309,8 @@
extents_data[1] = std::numeric_limits<double>::infinity();
extents_data[2] = -std::numeric_limits<double>::infinity();
extents_data[3] = -std::numeric_limits<double>::infinity();
+ xm = std::numeric_limits<double>::infinity();
+ ym = std::numeric_limits<double>::infinity();
::get_path_extents(path, trans,
&extents_data[0], &extents_data[1], &extents_data[2], &extents_data[3],
@@ -320,7 +322,7 @@
throw;
}
- return Py::Object((PyObject*)extents);
+ return Py::Object((PyObject*)extents, true);
}
Py::Object _path_module::update_path_extents(const Py::Tuple& args)
@@ -474,6 +476,8 @@
y0 = std::numeric_limits<double>::infinity();
x1 = -std::numeric_limits<double>::infinity();
y1 = -std::numeric_limits<double>::infinity();
+ xm = std::numeric_limits<double>::infinity();
+ ym = std::numeric_limits<double>::infinity();
agg::trans_affine trans;
for (i = 0; i < N; ++i)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-02-20 14:12:04
|
Revision: 4984
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4984&view=rev
Author: mdboom
Date: 2008-02-20 06:11:59 -0800 (Wed, 20 Feb 2008)
Log Message:
-----------
Fix memory leak in Gtk backend.
Modified Paths:
--------------
trunk/matplotlib/src/_path.cpp
Modified: trunk/matplotlib/src/_path.cpp
===================================================================
--- trunk/matplotlib/src/_path.cpp 2008-02-19 21:33:26 UTC (rev 4983)
+++ trunk/matplotlib/src/_path.cpp 2008-02-20 14:11:59 UTC (rev 4984)
@@ -1099,12 +1099,10 @@
polygon_array = (PyArrayObject*)PyArray_SimpleNew
(2, polygon_dims, PyArray_DOUBLE);
if (!polygon_array)
- {
throw Py::MemoryError("Error creating polygon array");
- }
double* polygon_data = (double*)PyArray_DATA(polygon_array);
memcpy(polygon_data, &polygon[0], polygon.size() * sizeof(double));
- polygons.append(Py::Object((PyObject*)polygon_array));
+ polygons.append(Py::Object((PyObject*)polygon_array, true));
}
Py::Object _path_module::convert_path_to_polygons(const Py::Tuple& args)
@@ -1133,6 +1131,8 @@
double x, y;
unsigned code;
+ polygon.reserve(path.total_vertices());
+
while ((code = curve.vertex(&x, &y)) != agg::path_cmd_stop)
{
if ((code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-02-21 19:13:50
|
Revision: 4986
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4986&view=rev
Author: mdboom
Date: 2008-02-21 11:13:46 -0800 (Thu, 21 Feb 2008)
Log Message:
-----------
Formatting and minor efficiency improvement.
Modified Paths:
--------------
trunk/matplotlib/src/_path.cpp
Modified: trunk/matplotlib/src/_path.cpp
===================================================================
--- trunk/matplotlib/src/_path.cpp 2008-02-21 19:13:14 UTC (rev 4985)
+++ trunk/matplotlib/src/_path.cpp 2008-02-21 19:13:46 UTC (rev 4986)
@@ -921,7 +921,7 @@
}
result = (PyArrayObject*)PyArray_SimpleNew
- (PyArray_NDIM(vertices), PyArray_DIMS(vertices), PyArray_DOUBLE);
+ (PyArray_NDIM(vertices), PyArray_DIMS(vertices), PyArray_DOUBLE);
if (PyArray_NDIM(vertices) == 2)
{
size_t n = PyArray_DIM(vertices, 0);
@@ -1017,17 +1017,17 @@
return Py::Int(count);
}
-bool segments_intersect(const double& x1, const double &y1,
- const double& x2, const double &y2,
- const double& x3, const double &y3,
- const double& x4, const double &y4)
+bool segments_intersect(const double& x1, const double& y1,
+ const double& x2, const double& y2,
+ const double& x3, const double& y3,
+ const double& x4, const double& y4)
{
- double den = ((y4-y3) * (x2-x1)) - ((x4-x3)*(y2-y1));
+ double den = ((y4-y3)*(x2-x1)) - ((x4-x3)*(y2-y1));
if (den == 0.0)
return false;
- double n1 = ((x4-x3) * (y1-y3)) - ((y4-y3)*(x1-x3));
- double n2 = ((x2-x1) * (y1-y3)) - ((y2-y1)*(x1-x3));
+ double n1 = ((x4-x3)*(y1-y3)) - ((y4-y3)*(x1-x3));
+ double n2 = ((x2-x1)*(y1-y3)) - ((y2-y1)*(x1-x3));
double u1 = n1/den;
double u2 = n2/den;
@@ -1075,20 +1075,9 @@
PathIterator p1(args[0]);
PathIterator p2(args[1]);
- bool intersects = ::path_intersects_path(p1, p2);
- if (!intersects)
- {
- intersects = ::path_in_path(p1, agg::trans_affine(), p2, agg::trans_affine());
- if (!intersects)
- {
- intersects = ::path_in_path(p2, agg::trans_affine(), p1, agg::trans_affine());
- if (!intersects)
- {
- return Py::Int(0);
- }
- }
- }
- return Py::Int(1);
+ return Py::Int(::path_intersects_path(p1, p2)
+ || ::path_in_path(p1, agg::trans_affine(), p2, agg::trans_affine())
+ || ::path_in_path(p2, agg::trans_affine(), p1, agg::trans_affine()));
}
void _add_polygon(Py::List& polygons, const std::vector<double>& polygon) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-02-25 20:24:38
|
Revision: 4988
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4988&view=rev
Author: mdboom
Date: 2008-02-25 12:24:33 -0800 (Mon, 25 Feb 2008)
Log Message:
-----------
Fix memory reservation for curve to line segment conversion.
Modified Paths:
--------------
trunk/matplotlib/src/_path.cpp
Modified: trunk/matplotlib/src/_path.cpp
===================================================================
--- trunk/matplotlib/src/_path.cpp 2008-02-25 20:21:39 UTC (rev 4987)
+++ trunk/matplotlib/src/_path.cpp 2008-02-25 20:24:33 UTC (rev 4988)
@@ -1120,7 +1120,7 @@
double x, y;
unsigned code;
- polygon.reserve(path.total_vertices());
+ polygon.reserve(path.total_vertices() * 2);
while ((code = curve.vertex(&x, &y)) != agg::path_cmd_stop)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-04-22 12:15:22
|
Revision: 5056
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5056&view=rev
Author: mdboom
Date: 2008-04-22 05:15:13 -0700 (Tue, 22 Apr 2008)
Log Message:
-----------
Removing my "bone-headed" "not"s and "or"s. Including "math.h" in an
attempt to get VS2003 working.
Modified Paths:
--------------
trunk/matplotlib/src/_path.cpp
Modified: trunk/matplotlib/src/_path.cpp
===================================================================
--- trunk/matplotlib/src/_path.cpp 2008-04-21 08:17:45 UTC (rev 5055)
+++ trunk/matplotlib/src/_path.cpp 2008-04-22 12:15:13 UTC (rev 5056)
@@ -1,3 +1,6 @@
+#include <limits>
+#include <math.h>
+
#include "agg_py_path_iterator.h"
#include "agg_py_transforms.h"
@@ -997,10 +1000,10 @@
std::swap(bx0, bx1);
if (by1 < by0)
std::swap(by0, by1);
- if (not ((bx1 <= ax0) or
- (by1 <= ay0) or
- (bx0 >= ax1) or
- (by0 >= ay1)))
+ if (!((bx1 <= ax0) ||
+ (by1 <= ay0) ||
+ (bx0 >= ax1) ||
+ (by0 >= ay1)))
++count;
}
else
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-05-02 16:57:48
|
Revision: 5105
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5105&view=rev
Author: mdboom
Date: 2008-05-02 09:57:45 -0700 (Fri, 02 May 2008)
Log Message:
-----------
Minor fixes.
Modified Paths:
--------------
trunk/matplotlib/src/_path.cpp
Modified: trunk/matplotlib/src/_path.cpp
===================================================================
--- trunk/matplotlib/src/_path.cpp 2008-05-02 16:55:59 UTC (rev 5104)
+++ trunk/matplotlib/src/_path.cpp 2008-05-02 16:57:45 UTC (rev 5105)
@@ -657,7 +657,8 @@
bisectx(double x) : m_x(x) {}
- void bisect(double sx, double sy, double px, double py, double* bx, double* by) const
+ inline void bisect(double sx, double sy, double px, double py,
+ double* bx, double* by) const
{
*bx = m_x;
double dx = px - sx;
@@ -670,7 +671,7 @@
{
xlt(double x) : bisectx(x) {}
- bool is_inside(double x, double y) const
+ inline bool is_inside(double x, double y) const
{
return x <= m_x;
}
@@ -680,7 +681,7 @@
{
xgt(double x) : bisectx(x) {}
- bool is_inside(double x, double y) const
+ inline bool is_inside(double x, double y) const
{
return x >= m_x;
}
@@ -692,7 +693,7 @@
bisecty(double y) : m_y(y) {}
- void bisect(double sx, double sy, double px, double py, double* bx, double* by) const
+ inline void bisect(double sx, double sy, double px, double py, double* bx, double* by) const
{
*by = m_y;
double dx = px - sx;
@@ -705,7 +706,7 @@
{
ylt(double y) : bisecty(y) {}
- bool is_inside(double x, double y) const
+ inline bool is_inside(double x, double y) const
{
return y <= m_y;
}
@@ -715,7 +716,7 @@
{
ygt(double y) : bisecty(y) {}
- bool is_inside(double x, double y) const
+ inline bool is_inside(double x, double y) const
{
return y >= m_y;
}
@@ -723,7 +724,7 @@
}
template<class Filter>
-void clip_to_rect_one_step(const Polygon& polygon, Polygon& result, const Filter& filter)
+inline void clip_to_rect_one_step(const Polygon& polygon, Polygon& result, const Filter& filter)
{
double sx, sy, px, py, bx, by;
bool sinside, pinside;
@@ -899,8 +900,9 @@
transform = (PyArrayObject*) PyArray_FromObject
(transform_obj.ptr(), PyArray_DOUBLE, 2, 2);
- if (!transform || PyArray_NDIM(transform) != 2 ||
- PyArray_DIM(transform, 0) != 3 || PyArray_DIM(transform, 1) != 3)
+ if (!transform ||
+ PyArray_DIM(transform, 0) != 3 ||
+ PyArray_DIM(transform, 1) != 3)
throw Py::ValueError("Invalid transform.");
double a, b, c, d, e, f;
@@ -964,6 +966,7 @@
Py_XDECREF(vertices);
Py_XDECREF(transform);
Py_XDECREF(result);
+ throw;
}
Py_XDECREF(vertices);
@@ -1020,10 +1023,10 @@
return Py::Int(count);
}
-bool segments_intersect(const double& x1, const double& y1,
- const double& x2, const double& y2,
- const double& x3, const double& y3,
- const double& x4, const double& y4)
+inline bool segments_intersect(const double& x1, const double& y1,
+ const double& x2, const double& y2,
+ const double& x3, const double& y3,
+ const double& x4, const double& y4)
{
double den = ((y4-y3)*(x2-x1)) - ((x4-x3)*(y2-y1));
if (den == 0.0)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|