Make use of psprintf() in recent changes
authorPeter Eisentraut
Tue, 22 Oct 2013 11:04:41 +0000 (07:04 -0400)
committerPeter Eisentraut
Tue, 22 Oct 2013 11:04:41 +0000 (07:04 -0400)
src/backend/utils/adt/geo_ops.c
src/backend/utils/error/elog.c

index b792d2697724f69351db7e16d3463cbc62c3398c..25f0bfd39438057f31adc5d1395f123585f4e651 100644 (file)
@@ -1010,16 +1010,12 @@ Datum
 line_out(PG_FUNCTION_ARGS)
 {
    LINE       *line = PG_GETARG_LINE_P(0);
-   char       *buf;
    int         ndig = DBL_DIG + extra_float_digits;
 
    if (ndig < 1)
        ndig = 1;
 
-   buf = palloc(ndig * 3 + 5);
-   sprintf(buf, "{%.*g,%.*g,%.*g}", ndig, line->A, ndig, line->B, ndig, line->C);
-
-   PG_RETURN_CSTRING(buf);
+   PG_RETURN_CSTRING(psprintf("{%.*g,%.*g,%.*g}", ndig, line->A, ndig, line->B, ndig, line->C));
 }
 
 /*
index eb62ff5054cceaeb34399272a841d73fc4527f4a..9c7489a9bb29d9bc55ceff89101dcf41156831c9 100644 (file)
@@ -2364,10 +2364,7 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
                             */
 
                            char *hostport;
-                           int alloclen = strlen(MyProcPort->remote_host) +
-                                strlen(MyProcPort->remote_port) + 3; 
-                           hostport = palloc(alloclen);
-                           sprintf(hostport, "%s(%s)", MyProcPort->remote_host, MyProcPort->remote_port);
+                           hostport = psprintf("%s(%s)", MyProcPort->remote_host, MyProcPort->remote_port);
                            appendStringInfo(buf, "%*s", padding, hostport);
                            pfree(hostport);
                        }