File tree 1 file changed +13
-7
lines changed
1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change 1
1
#include "types.h"
2
+ #include <stdarg.h>
2
3
3
4
#if !defined(PGSPHERE_VERSION )
4
5
#error "PGSPHERE_VERSION macro is not set"
@@ -384,7 +385,7 @@ spheretrans_out(PG_FUNCTION_ARGS)
384
385
{
385
386
SEuler * se = (SEuler * ) PG_GETARG_POINTER (0 );
386
387
char * buffer = (char * ) palloc (255 );
387
- char buf [100 ];
388
+ char * buf [336 ];
388
389
char etype [4 ];
389
390
SPoint val [3 ];
390
391
unsigned char i ,
@@ -412,21 +413,26 @@ spheretrans_out(PG_FUNCTION_ARGS)
412
413
{
413
414
414
415
case OUTPUT_DEG :
415
- sprintf ( & buf [ 0 ],
416
+ buf = psprintf (
416
417
"%.*gd" ,
417
- sphere_output_precision , RADIANS * val [i ].lng );
418
+ sphere_output_precision , RADIANS * val [i ].lng
419
+ );
418
420
break ;
419
421
420
422
case OUTPUT_HMS :
421
423
case OUTPUT_DMS :
422
424
rad_to_dms (val [i ].lng , & rdeg , & rmin , & rsec );
423
- sprintf ( & buf [ 0 ],
425
+ buf = psprintf (
424
426
"%2ud %2um %.*gs" ,
425
- rdeg , rmin , sphere_output_precision , rsec );
427
+ rdeg , rmin , sphere_output_precision , rsec
428
+ );
426
429
break ;
427
430
428
431
default :
429
- sprintf (& buf [0 ], "%.*g" , sphere_output_precision , val [i ].lng );
432
+ buf = psprintf (
433
+ "%.*g" ,
434
+ sphere_output_precision , val [i ].lng
435
+ );
430
436
break ;
431
437
}
432
438
strcat (& buf [0 ], ", " );
@@ -461,7 +467,7 @@ spheretrans_out(PG_FUNCTION_ARGS)
461
467
}
462
468
etype [3 ] = '\0' ;
463
469
strcat (buffer , etype );
464
-
470
+ pfree ( buf );
465
471
PG_RETURN_CSTRING (buffer );
466
472
}
467
473
You can’t perform that action at this time.
0 commit comments