mirror of
https://github.com/postgres/postgres.git
synced 2025-11-24 00:23:06 +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:
@@ -503,9 +503,7 @@ expand_dynamic_library_name(const char *name)
|
||||
pfree(full);
|
||||
}
|
||||
|
||||
new = palloc(strlen(name) + strlen(DLSUFFIX) + 1);
|
||||
strcpy(new, name);
|
||||
strcat(new, DLSUFFIX);
|
||||
new = psprintf("%s%s", name, DLSUFFIX);
|
||||
|
||||
if (!have_slash)
|
||||
{
|
||||
@@ -554,7 +552,6 @@ static char *
|
||||
substitute_libpath_macro(const char *name)
|
||||
{
|
||||
const char *sep_ptr;
|
||||
char *ret;
|
||||
|
||||
AssertArg(name != NULL);
|
||||
|
||||
@@ -572,12 +569,7 @@ substitute_libpath_macro(const char *name)
|
||||
errmsg("invalid macro name in dynamic library path: %s",
|
||||
name)));
|
||||
|
||||
ret = palloc(strlen(pkglib_path) + strlen(sep_ptr) + 1);
|
||||
|
||||
strcpy(ret, pkglib_path);
|
||||
strcat(ret, sep_ptr);
|
||||
|
||||
return ret;
|
||||
return psprintf("%s%s", pkglib_path, sep_ptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user