88 *
99 *
1010 * IDENTIFICATION
11- * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.60 2001/10/25 05:49:44 momjian Exp $
11+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.61 2002/05/14 18:16:51 tgl Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -1099,7 +1099,6 @@ line_distance(PG_FUNCTION_ARGS)
10991099PG_RETURN_FLOAT8 (fabs (l1 -> C - l2 -> C ));
11001100tmp = point_construct (0.0 ,l1 -> C );
11011101result = dist_pl_internal (tmp ,l2 );
1102- pfree (tmp );
11031102PG_RETURN_FLOAT8 (result );
11041103}
11051104
@@ -1843,8 +1842,6 @@ lseg_intersect_internal(LSEG *l1, LSEG *l2)
18431842retval = true;/* interpt on l1 and l2 */
18441843else
18451844retval = false;
1846- if (interpt != NULL )
1847- pfree (interpt );
18481845return retval ;
18491846}
18501847
@@ -2061,10 +2058,7 @@ lseg_interpt(PG_FUNCTION_ARGS)
20612058 */
20622059if (!on_ps_internal (result ,l1 )||
20632060!on_ps_internal (result ,l2 ))
2064- {
2065- pfree (result );
20662061PG_RETURN_NULL ();
2067- }
20682062
20692063/*
20702064 * If there is an intersection, then check explicitly for matching
@@ -2152,10 +2146,10 @@ dist_ps_internal(Point *pt, LSEG *lseg)
21522146ln -> A ,ln -> B ,ln -> C ,pt -> x ,pt -> y ,m );
21532147#endif
21542148
2155- /*
2156- * Calculate distance to the line segment
2157- * or to the endpoints of the segment.
2158- */
2149+ /*
2150+ * Calculate distance to the line segment
2151+ * or to the endpoints of the segment.
2152+ */
21592153
21602154/* intersection is on the line segment? */
21612155if ((ip = interpt_sl (lseg ,ln ))!= NULL )
@@ -2165,7 +2159,6 @@ dist_ps_internal(Point *pt, LSEG *lseg)
21652159printf ("dist_ps- distance is %f to intersection point is (%f,%f)\n" ,
21662160result ,ip -> x ,ip -> y );
21672161#endif
2168- pfree (ip );
21692162}
21702163else
21712164{
@@ -2176,8 +2169,6 @@ dist_ps_internal(Point *pt, LSEG *lseg)
21762169result = tmpdist ;
21772170}
21782171
2179- pfree (ln );
2180-
21812172return result ;
21822173}
21832174
@@ -2245,13 +2236,12 @@ dist_pb(PG_FUNCTION_ARGS)
22452236Point * pt = PG_GETARG_POINT_P (0 );
22462237BOX * box = PG_GETARG_BOX_P (1 );
22472238float8 result ;
2248- Point * tmp ;
2239+ Point * near ;
22492240
2250- tmp = DatumGetPointP (DirectFunctionCall2 (close_pb ,
2251- PointPGetDatum (pt ),
2252- BoxPGetDatum (box )));
2253- result = point_dt (tmp ,pt );
2254- pfree (tmp );
2241+ near = DatumGetPointP (DirectFunctionCall2 (close_pb ,
2242+ PointPGetDatum (pt ),
2243+ BoxPGetDatum (box )));
2244+ result = point_dt (near ,pt );
22552245
22562246PG_RETURN_FLOAT8 (result );
22572247}
@@ -2294,7 +2284,6 @@ dist_sb(PG_FUNCTION_ARGS)
22942284result = DirectFunctionCall2 (dist_pb ,
22952285PointPGetDatum (tmp ),
22962286BoxPGetDatum (box ));
2297- pfree (tmp );
22982287
22992288PG_RETURN_DATUM (result );
23002289}
@@ -2308,7 +2297,7 @@ dist_lb(PG_FUNCTION_ARGS)
23082297BOX * box = PG_GETARG_BOX_P (1 );
23092298#endif
23102299
2311- /* think about this one for a while */
2300+ /*need to think about this one for a while */
23122301elog (ERROR ,"dist_lb not implemented" );
23132302
23142303PG_RETURN_NULL ();
@@ -2401,7 +2390,6 @@ interpt_sl(LSEG *lseg, LINE *line)
24012390}
24022391else
24032392{
2404- pfree (p );
24052393p = NULL ;
24062394}
24072395}
@@ -2417,10 +2405,7 @@ has_interpt_sl(LSEG *lseg, LINE *line)
24172405
24182406tmp = interpt_sl (lseg ,line );
24192407if (tmp )
2420- {
2421- pfree (tmp );
24222408return true;
2423- }
24242409return false;
24252410}
24262411
@@ -2624,22 +2609,17 @@ close_lseg(PG_FUNCTION_ARGS)
26242609PointPGetDatum (& l2 -> p [0 ]),
26252610LsegPGetDatum (l1 )));
26262611memcpy (& point ,result ,sizeof (Point ));
2627- pfree (result );
26282612result = DatumGetPointP (DirectFunctionCall2 (close_ps ,
26292613PointPGetDatum (& point ),
26302614LsegPGetDatum (l2 )));
26312615}
26322616
26332617if ((d = dist_ps_internal (& l2 -> p [1 ],l1 ))< dist )
26342618{
2635- if (result != NULL )
2636- pfree (result );
2637-
26382619result = DatumGetPointP (DirectFunctionCall2 (close_ps ,
26392620PointPGetDatum (& l2 -> p [1 ]),
26402621LsegPGetDatum (l1 )));
26412622memcpy (& point ,result ,sizeof (Point ));
2642- pfree (result );
26432623result = DatumGetPointP (DirectFunctionCall2 (close_ps ,
26442624PointPGetDatum (& point ),
26452625LsegPGetDatum (l2 )));
@@ -3574,9 +3554,6 @@ box_mul(PG_FUNCTION_ARGS)
35743554
35753555result = box_construct (high -> x ,low -> x ,high -> y ,low -> y );
35763556
3577- pfree (high );
3578- pfree (low );
3579-
35803557PG_RETURN_BOX_P (result );
35813558}
35823559
@@ -3598,9 +3575,6 @@ box_div(PG_FUNCTION_ARGS)
35983575
35993576result = box_construct (high -> x ,low -> x ,high -> y ,low -> y );
36003577
3601- pfree (high );
3602- pfree (low );
3603-
36043578PG_RETURN_BOX_P (result );
36053579}
36063580
@@ -3700,7 +3674,6 @@ path_mul_pt(PG_FUNCTION_ARGS)
37003674PointPGetDatum (point )));
37013675path -> p [i ].x = p -> x ;
37023676path -> p [i ].y = p -> y ;
3703- pfree (p );
37043677}
37053678
37063679PG_RETURN_PATH_P (path );
@@ -3721,7 +3694,6 @@ path_div_pt(PG_FUNCTION_ARGS)
37213694PointPGetDatum (point )));
37223695path -> p [i ].x = p -> x ;
37233696path -> p [i ].y = p -> y ;
3724- pfree (p );
37253697}
37263698
37273699PG_RETURN_PATH_P (path );
@@ -3796,7 +3768,6 @@ poly_center(PG_FUNCTION_ARGS)
37963768PolygonPGetDatum (poly )));
37973769result = DirectFunctionCall1 (circle_center ,
37983770CirclePGetDatum (circle ));
3799- pfree (circle );
38003771
38013772PG_RETURN_DATUM (result );
38023773}
@@ -4232,7 +4203,6 @@ circle_mul_pt(PG_FUNCTION_ARGS)
42324203PointPGetDatum (point )));
42334204result -> center .x = p -> x ;
42344205result -> center .y = p -> y ;
4235- pfree (p );
42364206result -> radius *=HYPOT (point -> x ,point -> y );
42374207
42384208PG_RETURN_CIRCLE_P (result );
@@ -4253,7 +4223,6 @@ circle_div_pt(PG_FUNCTION_ARGS)
42534223PointPGetDatum (point )));
42544224result -> center .x = p -> x ;
42554225result -> center .y = p -> y ;
4256- pfree (p );
42574226result -> radius /=HYPOT (point -> x ,point -> y );
42584227
42594228PG_RETURN_CIRCLE_P (result );