Skip to content

Commit 586a8fc

Browse files
committed
Make use of psprintf() in recent changes
1 parent 36f4c78 commit 586a8fc

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

src/backend/utils/adt/geo_ops.c

+1-5
Original file line numberDiff line numberDiff line change
@@ -1010,16 +1010,12 @@ Datum
10101010
line_out(PG_FUNCTION_ARGS)
10111011
{
10121012
LINE *line = PG_GETARG_LINE_P(0);
1013-
char *buf;
10141013
int ndig = DBL_DIG + extra_float_digits;
10151014

10161015
if (ndig < 1)
10171016
ndig = 1;
10181017

1019-
buf = palloc(ndig * 3 + 5);
1020-
sprintf(buf, "{%.*g,%.*g,%.*g}", ndig, line->A, ndig, line->B, ndig, line->C);
1021-
1022-
PG_RETURN_CSTRING(buf);
1018+
PG_RETURN_CSTRING(psprintf("{%.*g,%.*g,%.*g}", ndig, line->A, ndig, line->B, ndig, line->C));
10231019
}
10241020

10251021
/*

src/backend/utils/error/elog.c

+1-4
Original file line numberDiff line numberDiff line change
@@ -2364,10 +2364,7 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
23642364
*/
23652365

23662366
char *hostport;
2367-
int alloclen = strlen(MyProcPort->remote_host) +
2368-
strlen(MyProcPort->remote_port) + 3;
2369-
hostport = palloc(alloclen);
2370-
sprintf(hostport, "%s(%s)", MyProcPort->remote_host, MyProcPort->remote_port);
2367+
hostport = psprintf("%s(%s)", MyProcPort->remote_host, MyProcPort->remote_port);
23712368
appendStringInfo(buf, "%*s", padding, hostport);
23722369
pfree(hostport);
23732370
}

0 commit comments

Comments
 (0)