xbps-pkgdb/check_pkg_symlinks: avoid many small allocations and fix a small memleak.