mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
Remove unnecessary pfree's in geometric operators. At least one of these
is actively dangerous, per bug report from Ewald Geschwinde 14-May-02, and several of the rest look suspicious to me. Since there is no longer any significant value in retail pfree's in these functions, just get rid of all of them for safety's sake.
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.60 2001/10/25 05:49:44 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.61 2002/05/14 18:16:51 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1099,7 +1099,6 @@ line_distance(PG_FUNCTION_ARGS)
|
|||||||
PG_RETURN_FLOAT8(fabs(l1->C - l2->C));
|
PG_RETURN_FLOAT8(fabs(l1->C - l2->C));
|
||||||
tmp = point_construct(0.0, l1->C);
|
tmp = point_construct(0.0, l1->C);
|
||||||
result = dist_pl_internal(tmp, l2);
|
result = dist_pl_internal(tmp, l2);
|
||||||
pfree(tmp);
|
|
||||||
PG_RETURN_FLOAT8(result);
|
PG_RETURN_FLOAT8(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1843,8 +1842,6 @@ lseg_intersect_internal(LSEG *l1, LSEG *l2)
|
|||||||
retval = true; /* interpt on l1 and l2 */
|
retval = true; /* interpt on l1 and l2 */
|
||||||
else
|
else
|
||||||
retval = false;
|
retval = false;
|
||||||
if (interpt != NULL)
|
|
||||||
pfree(interpt);
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2061,10 +2058,7 @@ lseg_interpt(PG_FUNCTION_ARGS)
|
|||||||
*/
|
*/
|
||||||
if (!on_ps_internal(result, l1) ||
|
if (!on_ps_internal(result, l1) ||
|
||||||
!on_ps_internal(result, l2))
|
!on_ps_internal(result, l2))
|
||||||
{
|
|
||||||
pfree(result);
|
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there is an intersection, then check explicitly for matching
|
* If there is an intersection, then check explicitly for matching
|
||||||
@ -2165,7 +2159,6 @@ dist_ps_internal(Point *pt, LSEG *lseg)
|
|||||||
printf("dist_ps- distance is %f to intersection point is (%f,%f)\n",
|
printf("dist_ps- distance is %f to intersection point is (%f,%f)\n",
|
||||||
result, ip->x, ip->y);
|
result, ip->x, ip->y);
|
||||||
#endif
|
#endif
|
||||||
pfree(ip);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2176,8 +2169,6 @@ dist_ps_internal(Point *pt, LSEG *lseg)
|
|||||||
result = tmpdist;
|
result = tmpdist;
|
||||||
}
|
}
|
||||||
|
|
||||||
pfree(ln);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2245,13 +2236,12 @@ dist_pb(PG_FUNCTION_ARGS)
|
|||||||
Point *pt = PG_GETARG_POINT_P(0);
|
Point *pt = PG_GETARG_POINT_P(0);
|
||||||
BOX *box = PG_GETARG_BOX_P(1);
|
BOX *box = PG_GETARG_BOX_P(1);
|
||||||
float8 result;
|
float8 result;
|
||||||
Point *tmp;
|
Point *near;
|
||||||
|
|
||||||
tmp = DatumGetPointP(DirectFunctionCall2(close_pb,
|
near = DatumGetPointP(DirectFunctionCall2(close_pb,
|
||||||
PointPGetDatum(pt),
|
PointPGetDatum(pt),
|
||||||
BoxPGetDatum(box)));
|
BoxPGetDatum(box)));
|
||||||
result = point_dt(tmp, pt);
|
result = point_dt(near, pt);
|
||||||
pfree(tmp);
|
|
||||||
|
|
||||||
PG_RETURN_FLOAT8(result);
|
PG_RETURN_FLOAT8(result);
|
||||||
}
|
}
|
||||||
@ -2294,7 +2284,6 @@ dist_sb(PG_FUNCTION_ARGS)
|
|||||||
result = DirectFunctionCall2(dist_pb,
|
result = DirectFunctionCall2(dist_pb,
|
||||||
PointPGetDatum(tmp),
|
PointPGetDatum(tmp),
|
||||||
BoxPGetDatum(box));
|
BoxPGetDatum(box));
|
||||||
pfree(tmp);
|
|
||||||
|
|
||||||
PG_RETURN_DATUM(result);
|
PG_RETURN_DATUM(result);
|
||||||
}
|
}
|
||||||
@ -2308,7 +2297,7 @@ dist_lb(PG_FUNCTION_ARGS)
|
|||||||
BOX *box = PG_GETARG_BOX_P(1);
|
BOX *box = PG_GETARG_BOX_P(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* think about this one for a while */
|
/* need to think about this one for a while */
|
||||||
elog(ERROR, "dist_lb not implemented");
|
elog(ERROR, "dist_lb not implemented");
|
||||||
|
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
@ -2401,7 +2390,6 @@ interpt_sl(LSEG *lseg, LINE *line)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pfree(p);
|
|
||||||
p = NULL;
|
p = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2417,10 +2405,7 @@ has_interpt_sl(LSEG *lseg, LINE *line)
|
|||||||
|
|
||||||
tmp = interpt_sl(lseg, line);
|
tmp = interpt_sl(lseg, line);
|
||||||
if (tmp)
|
if (tmp)
|
||||||
{
|
|
||||||
pfree(tmp);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2624,7 +2609,6 @@ close_lseg(PG_FUNCTION_ARGS)
|
|||||||
PointPGetDatum(&l2->p[0]),
|
PointPGetDatum(&l2->p[0]),
|
||||||
LsegPGetDatum(l1)));
|
LsegPGetDatum(l1)));
|
||||||
memcpy(&point, result, sizeof(Point));
|
memcpy(&point, result, sizeof(Point));
|
||||||
pfree(result);
|
|
||||||
result = DatumGetPointP(DirectFunctionCall2(close_ps,
|
result = DatumGetPointP(DirectFunctionCall2(close_ps,
|
||||||
PointPGetDatum(&point),
|
PointPGetDatum(&point),
|
||||||
LsegPGetDatum(l2)));
|
LsegPGetDatum(l2)));
|
||||||
@ -2632,14 +2616,10 @@ close_lseg(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
if ((d = dist_ps_internal(&l2->p[1], l1)) < dist)
|
if ((d = dist_ps_internal(&l2->p[1], l1)) < dist)
|
||||||
{
|
{
|
||||||
if (result != NULL)
|
|
||||||
pfree(result);
|
|
||||||
|
|
||||||
result = DatumGetPointP(DirectFunctionCall2(close_ps,
|
result = DatumGetPointP(DirectFunctionCall2(close_ps,
|
||||||
PointPGetDatum(&l2->p[1]),
|
PointPGetDatum(&l2->p[1]),
|
||||||
LsegPGetDatum(l1)));
|
LsegPGetDatum(l1)));
|
||||||
memcpy(&point, result, sizeof(Point));
|
memcpy(&point, result, sizeof(Point));
|
||||||
pfree(result);
|
|
||||||
result = DatumGetPointP(DirectFunctionCall2(close_ps,
|
result = DatumGetPointP(DirectFunctionCall2(close_ps,
|
||||||
PointPGetDatum(&point),
|
PointPGetDatum(&point),
|
||||||
LsegPGetDatum(l2)));
|
LsegPGetDatum(l2)));
|
||||||
@ -3574,9 +3554,6 @@ box_mul(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
result = box_construct(high->x, low->x, high->y, low->y);
|
result = box_construct(high->x, low->x, high->y, low->y);
|
||||||
|
|
||||||
pfree(high);
|
|
||||||
pfree(low);
|
|
||||||
|
|
||||||
PG_RETURN_BOX_P(result);
|
PG_RETURN_BOX_P(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3598,9 +3575,6 @@ box_div(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
result = box_construct(high->x, low->x, high->y, low->y);
|
result = box_construct(high->x, low->x, high->y, low->y);
|
||||||
|
|
||||||
pfree(high);
|
|
||||||
pfree(low);
|
|
||||||
|
|
||||||
PG_RETURN_BOX_P(result);
|
PG_RETURN_BOX_P(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3700,7 +3674,6 @@ path_mul_pt(PG_FUNCTION_ARGS)
|
|||||||
PointPGetDatum(point)));
|
PointPGetDatum(point)));
|
||||||
path->p[i].x = p->x;
|
path->p[i].x = p->x;
|
||||||
path->p[i].y = p->y;
|
path->p[i].y = p->y;
|
||||||
pfree(p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PG_RETURN_PATH_P(path);
|
PG_RETURN_PATH_P(path);
|
||||||
@ -3721,7 +3694,6 @@ path_div_pt(PG_FUNCTION_ARGS)
|
|||||||
PointPGetDatum(point)));
|
PointPGetDatum(point)));
|
||||||
path->p[i].x = p->x;
|
path->p[i].x = p->x;
|
||||||
path->p[i].y = p->y;
|
path->p[i].y = p->y;
|
||||||
pfree(p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PG_RETURN_PATH_P(path);
|
PG_RETURN_PATH_P(path);
|
||||||
@ -3796,7 +3768,6 @@ poly_center(PG_FUNCTION_ARGS)
|
|||||||
PolygonPGetDatum(poly)));
|
PolygonPGetDatum(poly)));
|
||||||
result = DirectFunctionCall1(circle_center,
|
result = DirectFunctionCall1(circle_center,
|
||||||
CirclePGetDatum(circle));
|
CirclePGetDatum(circle));
|
||||||
pfree(circle);
|
|
||||||
|
|
||||||
PG_RETURN_DATUM(result);
|
PG_RETURN_DATUM(result);
|
||||||
}
|
}
|
||||||
@ -4232,7 +4203,6 @@ circle_mul_pt(PG_FUNCTION_ARGS)
|
|||||||
PointPGetDatum(point)));
|
PointPGetDatum(point)));
|
||||||
result->center.x = p->x;
|
result->center.x = p->x;
|
||||||
result->center.y = p->y;
|
result->center.y = p->y;
|
||||||
pfree(p);
|
|
||||||
result->radius *= HYPOT(point->x, point->y);
|
result->radius *= HYPOT(point->x, point->y);
|
||||||
|
|
||||||
PG_RETURN_CIRCLE_P(result);
|
PG_RETURN_CIRCLE_P(result);
|
||||||
@ -4253,7 +4223,6 @@ circle_div_pt(PG_FUNCTION_ARGS)
|
|||||||
PointPGetDatum(point)));
|
PointPGetDatum(point)));
|
||||||
result->center.x = p->x;
|
result->center.x = p->x;
|
||||||
result->center.y = p->y;
|
result->center.y = p->y;
|
||||||
pfree(p);
|
|
||||||
result->radius /= HYPOT(point->x, point->y);
|
result->radius /= HYPOT(point->x, point->y);
|
||||||
|
|
||||||
PG_RETURN_CIRCLE_P(result);
|
PG_RETURN_CIRCLE_P(result);
|
||||||
|
Reference in New Issue
Block a user