static struct ppc64_vendor * ppc64VendorParse(xmlXPathContextPtr ctxt, struct ppc64_map *map) { struct ppc64_vendor *vendor; if (VIR_ALLOC(vendor) < 0) return NULL; vendor->name = virXPathString("string(@name)", ctxt); if (!vendor->name) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing CPU vendor name")); goto error; } if (ppc64VendorFind(map, vendor->name)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("CPU vendor %s already defined"), vendor->name); goto error; } return vendor; error: ppc64VendorFree(vendor); return NULL; }
static void ppc64MapFree(struct ppc64_map *map) { size_t i; if (!map) return; for (i = 0; i < map->nmodels; i++) ppc64ModelFree(map->models[i]); VIR_FREE(map->models); for (i = 0; i < map->nvendors; i++) ppc64VendorFree(map->vendors[i]); VIR_FREE(map->vendors); VIR_FREE(map); }
static void ppc64MapFree(struct ppc64_map *map) { if (map == NULL) return; while (map->models != NULL) { struct ppc64_model *model = map->models; map->models = model->next; ppc64ModelFree(model); } while (map->vendors != NULL) { struct ppc64_vendor *vendor = map->vendors; map->vendors = vendor->next; ppc64VendorFree(vendor); } VIR_FREE(map); }
static int ppc64VendorLoad(xmlXPathContextPtr ctxt, struct ppc64_map *map) { struct ppc64_vendor *vendor = NULL; if (VIR_ALLOC(vendor) < 0) return -1; vendor->name = virXPathString("string(@name)", ctxt); if (!vendor->name) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing CPU vendor name")); goto ignore; } if (ppc64VendorFind(map, vendor->name)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("CPU vendor %s already defined"), vendor->name); goto ignore; } if (!map->vendors) { map->vendors = vendor; } else { vendor->next = map->vendors; map->vendors = vendor; } cleanup: return 0; ignore: ppc64VendorFree(vendor); goto cleanup; }