void pkgset_blank(struct pkgset *set) { set->name = NULL; set->depended.available = NULL; set->depended.installed = NULL; pkg_blank(&set->pkg); set->pkg.set = set; }
void pkgset_blank(struct pkgset *set) { set->name = NULL; set->depended.available = NULL; set->depended.installed = NULL; pkg_blank(&set->pkg); set->installed_instances = 0; set->pkg.set = set; set->pkg.arch_next = NULL; }
/** * Return the package instance in a set with the given architecture. * * It traverse the various instances to find out whether there's one * matching the given architecture. If found, it returns it. Otherwise it * allocates a new instance and registers it in the package set before * returning it. * * @param set The package set to use. * @param arch The requested architecture. * * @return The package instance. */ struct pkginfo * pkg_hash_get_pkg(struct pkgset *set, const struct dpkg_arch *arch) { struct pkginfo *pkg, **pkgp; if (arch == NULL) internerr("arch argument is NULL"); if (arch->type == DPKG_ARCH_NONE) internerr("arch argument is none"); pkg = &set->pkg; /* If there's a single unused slot, let's use that. */ if (pkg->installed.arch->type == DPKG_ARCH_NONE && pkg->arch_next == NULL) { /* We can only initialize the arch pkgbin members, because those are used * to find instances, anything else will be overwritten at parse time. */ pkg->installed.arch = arch; pkg->available.arch = arch; return pkg; } /* Match the slot with the most appropriate architecture. The installed * architecture always has preference over the available one, as there's * a small time window on cross-grades, where they might differ. */ for (pkgp = &pkg; *pkgp; pkgp = &(*pkgp)->arch_next) { if ((*pkgp)->installed.arch == arch) return *pkgp; } /* Need to create a new instance for the wanted architecture. */ pkg = nfmalloc(sizeof(*pkg)); pkg_blank(pkg); pkg->set = set; pkg->arch_next = NULL; /* We can only initialize the arch pkgbin members, because those are used * to find instances, anything else will be overwritten at parse time. */ pkg->installed.arch = arch; pkg->available.arch = arch; *pkgp = pkg; npkg++; return pkg; }