diff options
author | Peter Eisentraut | 2013-10-13 04:09:18 +0000 |
---|---|---|
committer | Peter Eisentraut | 2013-10-13 04:09:18 +0000 |
commit | 5b6d08cd2992922b667564a49f19580f11676050 (patch) | |
tree | 4104a4255eeb88e78da71477b5f7b129f9a1b599 /src/test/isolation/isolationtester.c | |
parent | a53dee43fe585e673658b01e7354892dcede957e (diff) |
Add use of asprintf()
Add asprintf(), pg_asprintf(), and psprintf() to simplify string
allocation and composition. Replacement implementations taken from
NetBSD.
Reviewed-by: Álvaro Herrera <[email protected]>
Reviewed-by: Asif Naeem <[email protected]>
Diffstat (limited to 'src/test/isolation/isolationtester.c')
-rw-r--r-- | src/test/isolation/isolationtester.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/test/isolation/isolationtester.c b/src/test/isolation/isolationtester.c index f62565046c3..7a3572f0c17 100644 --- a/src/test/isolation/isolationtester.c +++ b/src/test/isolation/isolationtester.c @@ -466,8 +466,7 @@ report_two_error_messages(Step * step1, Step * step2) { char *prefix; - prefix = malloc(strlen(step1->name) + strlen(step2->name) + 2); - sprintf(prefix, "%s %s", step1->name, step2->name); + pg_asprintf(&prefix, "%s %s", step1->name, step2->name); if (step1->errormsg) { @@ -795,12 +794,9 @@ try_complete_step(Step * step, int flags) PG_DIAG_MESSAGE_PRIMARY); if (sev && msg) - { - step->errormsg = malloc(5 + strlen(sev) + strlen(msg)); - sprintf(step->errormsg, "%s: %s", sev, msg); - } + pg_asprintf(&step->errormsg, "%s: %s", sev, msg); else - step->errormsg = strdup(PQresultErrorMessage(res)); + step->errormsg = pg_strdup(PQresultErrorMessage(res)); } break; default: |