svn commit: r366828 - head/usr.sbin/pkg
Baptiste Daroussin
bapt at FreeBSD.org
Mon Oct 19 07:26:42 UTC 2020
Author: bapt
Date: Mon Oct 19 07:26:42 2020
New Revision: 366828
URL: https://svnweb.freebsd.org/changeset/base/366828
Log:
Use asprintf instead of sbuf
Modified:
head/usr.sbin/pkg/config.c
Modified: head/usr.sbin/pkg/config.c
==============================================================================
--- head/usr.sbin/pkg/config.c Mon Oct 19 07:03:04 2020 (r366827)
+++ head/usr.sbin/pkg/config.c Mon Oct 19 07:26:42 2020 (r366828)
@@ -32,8 +32,8 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/queue.h>
-#include <sys/sbuf.h>
#include <sys/utsname.h>
+#include <sys/sbuf.h>
#include <sys/sysctl.h>
#include <dirent.h>
@@ -168,7 +168,7 @@ pkg_get_myabi(char *dest, size_t sz)
static void
subst_packagesite(const char *abi)
{
- struct sbuf *newval;
+ char *newval;
const char *variable_string;
const char *oldval;
@@ -180,14 +180,14 @@ subst_packagesite(const char *abi)
if ((variable_string = strstr(oldval, "${ABI}")) == NULL)
return;
- newval = sbuf_new_auto();
- sbuf_bcat(newval, oldval, variable_string - oldval);
- sbuf_cat(newval, abi);
- sbuf_cat(newval, variable_string + strlen("${ABI}"));
- sbuf_finish(newval);
+ asprintf(&newval, "%.*s%s%s",
+ (int)(variable_string - oldval), oldval, abi,
+ variable_string + strlen("${ABI}"));
+ if (newval == NULL)
+ errx(EXIT_FAILURE, "asprintf");
free(c[PACKAGESITE].value);
- c[PACKAGESITE].value = strdup(sbuf_data(newval));
+ c[PACKAGESITE].value = newval;
}
static int
More information about the svn-src-head
mailing list