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:
@ -556,17 +556,16 @@ xbps_repo_get_pkg_revdeps(struct xbps_repo *repo, const char *pkg)
|
||||
*/
|
||||
if ((vdeps = xbps_dictionary_get(pkgd, "provides"))) {
|
||||
for (unsigned int i = 0; i < xbps_array_count(vdeps); i++) {
|
||||
char *vpkgn;
|
||||
char vpkgn[XBPS_NAME_SIZE];
|
||||
|
||||
xbps_array_get_cstring_nocopy(vdeps, i, &vpkg);
|
||||
vpkgn = xbps_pkg_name(vpkg);
|
||||
assert(vpkgn);
|
||||
if (!xbps_pkg_name(vpkgn, XBPS_NAME_SIZE, vpkg)) {
|
||||
abort();
|
||||
}
|
||||
if (strcmp(vpkgn, pkg) == 0) {
|
||||
free(vpkgn);
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
free(vpkgn);
|
||||
vpkg = NULL;
|
||||
}
|
||||
if (match)
|
||||
|
Reference in New Issue
Block a user