File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -506,20 +506,22 @@ spherepath_in(PG_FUNCTION_ARGS)
506506 char * c = PG_GETARG_CSTRING (0 );
507507 int32 i , nelem ;
508508 void sphere_yyparse (void );
509+ SPoint * arr ;
509510
510511 init_buffer (c );
511512 sphere_yyparse ();
512513
513514 nelem = get_path_count ();
514515 if (nelem > 1 )
515516 {
516- SPoint arr [ nelem ] ;
517+ arr = ( SPoint * ) palloc ( sizeof ( SPoint ) * nelem ) ;
517518
518519 for (i = 0 ; i < nelem ; i ++ )
519520 {
520521 get_path_elem (i , & arr [i ].lng , & arr [i ].lat );
521522 }
522523 path = spherepath_from_array (& arr [0 ], nelem );
524+ pfree (arr );
523525 }
524526 else
525527 {
Original file line number Diff line number Diff line change @@ -815,6 +815,7 @@ spherepoly_in(PG_FUNCTION_ARGS)
815815 char * c = PG_GETARG_CSTRING (0 );
816816 int32 i ,
817817 nelem ;
818+ SPoint * arr ;
818819
819820 void sphere_yyparse (void );
820821
@@ -824,13 +825,14 @@ spherepoly_in(PG_FUNCTION_ARGS)
824825 nelem = get_path_count ();
825826 if (nelem > 2 )
826827 {
827- SPoint arr [ nelem ] ;
828+ arr = ( SPoint * ) palloc ( sizeof ( SPoint ) * nelem ) ;
828829
829830 for (i = 0 ; i < nelem ; i ++ )
830831 {
831832 get_path_elem (i , & arr [i ].lng , & arr [i ].lat );
832833 }
833834 poly = spherepoly_from_array (& arr [0 ], nelem );
835+ pfree (arr );
834836 }
835837 else
836838 {
@@ -892,11 +894,12 @@ spherepoly_area(PG_FUNCTION_ARGS)
892894{
893895 SPOLY * poly = PG_GETARG_SPOLY (0 );
894896 int32 i ;
895- SPoint s [ poly -> npts + 2 ] ;
897+ SPoint * s ;
896898 SPoint stmp [2 ];
897899 SEuler se ;
898900 float8 sum = 0.0 ;
899901
902+ s = (SPoint * )palloc (sizeof (SPoint )* (poly -> npts + 2 ));
900903 memcpy ((void * ) & s [1 ],
901904 (void * ) & poly -> p [0 ],
902905 poly -> npts * sizeof (SPoint ));
@@ -936,6 +939,7 @@ spherepoly_area(PG_FUNCTION_ARGS)
936939 sum = 0.0 ;
937940 }
938941
942+ pfree (s );
939943 PG_RETURN_FLOAT8 (sum );
940944}
941945
You can’t perform that action at this time.
0 commit comments