mirror of
https://github.com/postgres/postgres.git
synced 2025-07-14 08:21:07 +03:00
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 <alvherre@2ndquadrant.com> Reviewed-by: Asif Naeem <anaeem.it@gmail.com>
This commit is contained in:
@ -3822,7 +3822,6 @@ static char **
|
||||
complete_from_variables(char *text, const char *prefix, const char *suffix)
|
||||
{
|
||||
char **matches;
|
||||
int overhead = strlen(prefix) + strlen(suffix) + 1;
|
||||
char **varnames;
|
||||
int nvars = 0;
|
||||
int maxvars = 100;
|
||||
@ -3847,8 +3846,7 @@ complete_from_variables(char *text, const char *prefix, const char *suffix)
|
||||
}
|
||||
}
|
||||
|
||||
buffer = (char *) pg_malloc(strlen(ptr->name) + overhead);
|
||||
sprintf(buffer, "%s%s%s", prefix, ptr->name, suffix);
|
||||
pg_asprintf(&buffer, "%s%s%s", prefix, ptr->name, suffix);
|
||||
varnames[nvars++] = buffer;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user