libxbps: ABI/API break due to xbps_pkg{,pattern}_name changes.
The funcs xbps_pkg_name() and xbps_pkgpattern_name() were using malloc(3) to return the result, until now. They now have been changed to not allocate the result via malloc, the caller is responsible to provide a buffer at least of XBPS_NAME_SIZE (64). If for whatever reason the pkgname can't be guessed, returns false. This should avoid lots of small allocs around libxbps. New functions have the following prototype: bool xbps_pkg_name(char *dst, size_t len, const char *pkg) bool xbps_pkgpattern_name(char *dst, size_t len, const char *pkg) as suggested by @duncaen.
This commit is contained in:
@ -830,7 +830,7 @@ main(int argc, char **argv)
|
||||
const char *arch, *config_files, *mutable_files, *version, *changelog;
|
||||
const char *buildopts, *shlib_provides, *shlib_requires, *alternatives;
|
||||
const char *compression, *tags = NULL, *srcrevs = NULL;
|
||||
char *pkgname, *binpkg, *tname, *p, cwd[PATH_MAX-1];
|
||||
char pkgname[XBPS_NAME_SIZE], *binpkg, *tname, *p, cwd[PATH_MAX-1];
|
||||
bool quiet = false, preserve = false;
|
||||
int c, pkg_fd;
|
||||
mode_t myumask;
|
||||
@ -947,8 +947,7 @@ main(int argc, char **argv)
|
||||
/*
|
||||
* Sanity check for required options.
|
||||
*/
|
||||
pkgname = xbps_pkg_name(pkgver);
|
||||
if (pkgname == NULL)
|
||||
if (!xbps_pkg_name(pkgname, sizeof(pkgname), pkgver))
|
||||
die("invalid pkgver! got `%s' expected `foo-1.0_1'", pkgver);
|
||||
version = xbps_pkg_version(pkgver);
|
||||
if (version == NULL)
|
||||
|
Reference in New Issue
Block a user