Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb9b4431

Browse files
committed
Fix compiler error related to explicit allocation of variable size
arrays
1 parente0b303d commitb9b4431

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

‎path.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,20 +506,22 @@ spherepath_in(PG_FUNCTION_ARGS)
506506
char*c=PG_GETARG_CSTRING(0);
507507
int32i,nelem;
508508
voidsphere_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-
SPointarr[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
{

‎polygon.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,7 @@ spherepoly_in(PG_FUNCTION_ARGS)
815815
char*c=PG_GETARG_CSTRING(0);
816816
int32i,
817817
nelem;
818+
SPoint*arr;
818819

819820
voidsphere_yyparse(void);
820821

@@ -824,13 +825,14 @@ spherepoly_in(PG_FUNCTION_ARGS)
824825
nelem=get_path_count();
825826
if (nelem>2)
826827
{
827-
SPointarr[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
int32i;
895-
SPoints[poly->npts+2];
897+
SPoint*s;
896898
SPointstmp[2];
897899
SEulerse;
898900
float8sum=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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp