libxbps: use memcpy in critical paths for performance, fixed some memleaks.

This commit is contained in:
Juan RP
2012-06-18 10:43:05 +02:00
parent 3e93d235ff
commit c24ce8e4da
6 changed files with 28 additions and 27 deletions

View File

@ -150,7 +150,9 @@ xbps_pkg_name(const char *pkg)
len = strlen(pkg) - strlen(p) + 1;
buf = malloc(len);
assert(buf != NULL);
strlcpy(buf, pkg, len);
memcpy(buf, pkg, len-1);
buf[len-1] = '\0';
return buf;
}
@ -172,7 +174,9 @@ xbps_pkgpattern_name(const char *pkg)
pkgname = malloc(len);
assert(pkgname != NULL);
strlcpy(pkgname, pkg, len);
memcpy(pkgname, pkg, len-1);
pkgname[len-1] = '\0';
return pkgname;
}