goto release_filters;
/* Alloc mem needed for the filters now */
- if (VIR_ALLOC_N(def->hostdevs, def->nhostdevs) < 0)
- goto release_filters;
+ def->hostdevs = g_new0(virDomainHostdevDefPtr, def->nhostdevs);
for (i = 0; i < def->nhostdevs; i++) {
def->hostdevs[i] = virDomainHostdevDefNew();
}
/* Allocate mem, if fails return error */
- if (VIR_ALLOC_N(def->disks, def->ndisks) < 0)
- goto cleanup;
+ def->disks = g_new0(virDomainDiskDefPtr, def->ndisks);
for (i = 0; i < def->ndisks; i++) {
disk = virDomainDiskDefNew(NULL);
PRBool accelerate2DEnabled = PR_FALSE;
/* Currently supports only one graphics card */
- if (VIR_ALLOC_N(def->videos, 1) < 0)
- return -1;
+ def->videos = g_new0(virDomainVideoDefPtr, 1);
def->nvideos = 1;
- if (VIR_ALLOC(def->videos[0]) < 0)
- return -1;
+ def->videos[0] = g_new0(virDomainVideoDef, 1);
gVBoxAPI.UIMachine.GetVRAMSize(machine, &VRAMSize);
gVBoxAPI.UIMachine.GetMonitorCount(machine, &monitorCount);
def->videos[0]->type = VIR_DOMAIN_VIDEO_TYPE_VBOX;
def->videos[0]->vram = VRAMSize * 1024;
def->videos[0]->heads = monitorCount;
- if (VIR_ALLOC(def->videos[0]->accel) < 0)
- return -1;
+ def->videos[0]->accel = g_new0(virDomainVideoAccelDef, 1);
def->videos[0]->accel->accel3d = accelerate3DEnabled ?
VIR_TRISTATE_BOOL_YES : VIR_TRISTATE_BOOL_NO;
def->videos[0]->accel->accel2d = accelerate2DEnabled ?
PRUnichar *valueDisplayUtf16 = NULL;
char *valueDisplayUtf8 = NULL;
- if (VIR_ALLOC(graphics) < 0)
- goto cleanup;
+ graphics = g_new0(virDomainGraphicsDef, 1);
VBOX_UTF8_TO_UTF16("FRONTEND/Display", &keyUtf16);
gVBoxAPI.UIMachine.GetExtraData(machine, keyUtf16, &valueDisplayUtf16);
}
VBOX_UTF8_FREE(valueDisplayUtf8);
} else if (STRNEQ_NULLABLE(valueTypeUtf8, "vrdp")) {
- if (VIR_ALLOC(graphics) < 0)
- goto cleanup;
+ graphics = g_new0(virDomainGraphicsDef, 1);
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP;
graphics->data.desktop.display = g_strdup(getenv("DISPLAY"));
PRBool allowMultiConnection = PR_FALSE;
PRBool reuseSingleConnection = PR_FALSE;
- if (VIR_ALLOC(graphics) < 0)
- goto cleanup;
+ graphics = g_new0(virDomainGraphicsDef, 1);
gVBoxAPI.UIVRDEServer.GetPorts(data, VRDEServer, machine, graphics);
goto cleanup;
}
- if (VIR_ALLOC_N(def->fss, sharedFolders.count) < 0)
- goto cleanup;
+ def->fss = g_new0(virDomainFSDefPtr, sharedFolders.count);
for (i = 0; i < sharedFolders.count; i++) {
ISharedFolder *sharedFolder = sharedFolders.items[i];
PRUint32 audioController = AudioControllerType_AC97;
def->nsounds = 1;
- if (VIR_ALLOC_N(def->sounds, def->nsounds) < 0)
- return;
- if (VIR_ALLOC(def->sounds[0]) < 0)
- return;
+ def->sounds = g_new0(virDomainSoundDefPtr, 1);
+ def->sounds[0] = g_new0(virDomainSoundDef, 1);
gVBoxAPI.UIAudioAdapter.GetAudioController(audioAdapter, &audioController);
if (audioController == AudioControllerType_SB16) {
/* Allocate memory for the serial ports which are enabled */
if (def->nserials > 0) {
- if (VIR_ALLOC_N(def->serials, def->nserials) < 0)
- return -1;
+ def->serials = g_new0(virDomainChrDefPtr, def->nserials);
for (i = 0; i < def->nserials; i++) {
def->serials[i] = virDomainChrDefNew(NULL);
/* Allocate memory for the parallel ports which are enabled */
if (def->nparallels > 0) {
- if (VIR_ALLOC_N(def->parallels, def->nparallels) < 0)
- return -1;
+ def->parallels = g_new0(virDomainChrDefPtr, def->nparallels);
for (i = 0; i < def->nparallels; i++) {
def->parallels[i] = virDomainChrDefNew(NULL);
VBOX_UTF16_TO_UTF8(formatUtf, &format);
VBOX_UTF16_FREE(formatUtf);
- if (VIR_ALLOC(readWriteDisk) < 0) {
- VIR_FREE(formatUtf);
- goto cleanup;
- }
+ readWriteDisk = g_new0(virVBoxSnapshotConfHardDisk, 1);
readWriteDisk->format = format;
readWriteDisk->uuid = uuid;
goto cleanup;
}
- if (VIR_ALLOC(readOnlyDisk) < 0) {
- VIR_FREE(uuid);
- VIR_FREE(parentUuid);
- goto cleanup;
- }
+ readOnlyDisk = g_new0(virVBoxSnapshotConfHardDisk, 1);
readOnlyDisk->format = format;
readOnlyDisk->uuid = uuid;
/* Here, all disks are closed or deleted */
/* We are now going to create and fill the Snapshot xml struct */
- if (VIR_ALLOC(newSnapshotPtr) < 0)
- goto cleanup;
+ newSnapshotPtr = g_new0(virVBoxSnapshotConfSnapshot, 1);
if (virUUIDGenerate(snapshotUuid) < 0)
goto cleanup;
}
VBOX_UTF16_FREE(locationUtf16);
- if (VIR_ALLOC(disk) < 0)
- goto cleanup;
+ disk = g_new0(virVBoxSnapshotConfHardDisk, 1);
rc = gVBoxAPI.UIMedium.GetFormat(medium, &formatUtf16);
if (NS_FAILED(rc)) {
* media registry and the machine storage controllers.
*/
- if (VIR_ALLOC(newHardDisk) < 0)
- goto cleanup;
+ newHardDisk = g_new0(virVBoxSnapshotConfHardDisk, 1);
rc = gVBoxAPI.UIMedium.GetId(newMedium, &iid);
if (NS_FAILED(rc)) {
if (count == 0)
goto out;
- if (VIR_ALLOC_N(list, count) < 0)
- goto error;
+ list = g_new0(ISnapshot *, count);
rc = gVBoxAPI.UIMachine.FindSnapshot(machine, &empty, list);
if (NS_FAILED(rc) || !list[0]) {
}
}
/* Allocate mem, if fails return error */
- if (VIR_ALLOC_N(def->disks, def->ndisks) < 0)
- goto cleanup;
+ def->disks = g_new0(virDomainSnapshotDiskDef, def->ndisks);
for (i = 0; i < def->ndisks; i++) {
- if (VIR_ALLOC(def->disks[i].src) < 0)
- goto cleanup;
+ def->disks[i].src = g_new0(virStorageSource, 1);
}
/* get the attachment details here */
}
/* Allocate mem, if fails return error */
- if (VIR_ALLOC_N(defdom->disks, defdom->ndisks) < 0)
- goto cleanup;
+ defdom->disks = g_new0(virDomainDiskDefPtr, defdom->ndisks);
for (i = 0; i < defdom->ndisks; i++) {
virDomainDiskDefPtr diskDef = virDomainDiskDefNew(NULL);
vboxIID empty;
VBOX_IID_INITIALIZE(&empty);
- if (VIR_ALLOC_N(snapshots, 1) < 0)
- goto cleanup;
+ snapshots = g_new0(ISnapshot *, 1);
rc = gVBoxAPI.UIMachine.FindSnapshot(machine, &empty, snapshots);
if (NS_FAILED(rc) || !snapshots[0]) {
virReportError(VIR_ERR_INTERNAL_ERROR,
* the machine storage controller.
*/
- if (VIR_ALLOC(disk) < 0)
- goto cleanup;
+ disk = g_new0(virVBoxSnapshotConfHardDisk, 1);
rc = gVBoxAPI.UIMedium.GetId(newMedium, &iid);
if (NS_FAILED(rc)) {
!MATCH(VIR_CONNECT_LIST_DOMAINS_NO_AUTOSTART)) ||
(MATCH(VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE) &&
!MATCH(VIR_CONNECT_LIST_DOMAINS_NO_MANAGEDSAVE))) {
- if (domains &&
- VIR_ALLOC_N(*domains, 1) < 0)
- goto cleanup;
+ if (domains)
+ *domains = g_new0(virDomainPtr, 1);
ret = 0;
goto cleanup;
goto cleanup;
}
- if (domains &&
- VIR_ALLOC_N(doms, machines.count + 1) < 0)
- goto cleanup;
+ if (domains)
+ doms = g_new0(virDomainPtr, machines.count + 1);
for (i = 0; i < machines.count; i++) {
IMachine *machine = machines.items[i];
keyDownCodes = (PRInt32 *) keycodes;
- if (VIR_ALLOC_N(keyUpCodes, nkeycodes) < 0)
- return ret;
+ keyUpCodes = g_new0(PRInt32, nkeycodes);
/* translate keycodes to xt and generate keyup scancodes */
for (i = 0; i < nkeycodes; i++) {
char *location = NULL;
char *tmp = NULL;
int n = 0;
- if (VIR_ALLOC(hardDisk) < 0)
- goto cleanup;
+
+ hardDisk = g_new0(virVBoxSnapshotConfHardDisk, 1);
xPathContext->node = diskNode;
if (n < 0)
goto cleanup;
- if (n && VIR_ALLOC_N(hardDisk->children, n) < 0)
- goto cleanup;
+ if (n)
+ hardDisk->children = g_new0(virVBoxSnapshotConfHardDiskPtr, n);
hardDisk->nchildren = n;
for (i = 0; i < hardDisk->nchildren; i++) {
hardDisk->children[i] = virVBoxSnapshotConfCreateVBoxSnapshotConfHardDiskPtr(nodes[i], xPathContext, machineLocation);
int result = -1;
int n = 0;
- if (VIR_ALLOC(mediaRegistry) < 0)
- goto cleanup;
+ mediaRegistry = g_new0(virVBoxSnapshotConfMediaRegistry, 1);
xPathContext->node = mediaRegistryNode;
hardDisksNode = virXPathNode("./vbox:HardDisks", xPathContext);
n = virXPathNodeSet("./vbox:HardDisk", xPathContext, &nodes);
if (n < 0)
goto cleanup;
- if (n && VIR_ALLOC_N(mediaRegistry->disks, n) < 0)
- goto cleanup;
+ if (n)
+ mediaRegistry->disks = g_new0(virVBoxSnapshotConfHardDiskPtr, n);
mediaRegistry->ndisks = n;
for (i = 0; i < mediaRegistry->ndisks; i++) {
mediaRegistry->disks[i] = virVBoxSnapshotConfCreateVBoxSnapshotConfHardDiskPtr(nodes[i],
xPathContext, &nodes);
if (n < 0)
goto cleanup;
- if (n && VIR_ALLOC_N(mediaRegistry->otherMedia, n) < 0)
- goto cleanup;
+ if (n)
+ mediaRegistry->otherMedia = g_new0(char *, n);
+
mediaRegistry->notherMedia = n;
for (i = 0; i < mediaRegistry->notherMedia; i++) {
mediaRegistry->otherMedia[i] = virXMLNodeToString(mediaRegistryNode->doc,
int result = -1;
int n = 0;
- if (VIR_ALLOC(snapshot) < 0)
- goto cleanup;
+ snapshot = g_new0(virVBoxSnapshotConfSnapshot, 1);
uuid = virXMLPropString(snapshotNode, "uuid");
/* we use virStringSearch because the uuid is between brackets */
n = virXPathNodeSet("./vbox:Snapshot", xPathContext, &nodes);
if (n < 0)
goto cleanup;
- if (n && VIR_ALLOC_N(snapshot->children, n) < 0)
- goto cleanup;
+ if (n)
+ snapshot->children = g_new0(virVBoxSnapshotConfSnapshotPtr, n);
snapshot->nchildren = n;
for (i = 0; i < snapshot->nchildren; i++) {
snapshot->children[i] = virVBoxSnapshotConfRetrieveSnapshot(nodes[i], xPathContext);
size_t i = 0;
size_t j = 0;
- if (VIR_ALLOC_N(ret, 0) < 0)
- return 0;
+ ret = g_new0(virVBoxSnapshotConfHardDiskPtr, 0);
for (i = 0; i < disk->nchildren; i++) {
tempSize = virVBoxSnapshotConfAllChildren(disk->children[i], &tempList);
goto cleanup;
}
- if (VIR_ALLOC(machineDescription) < 0)
- goto cleanup;
+ machineDescription = g_new0(virVBoxSnapshotConfMachine, 1);
xml = virXMLParse(filePath, NULL, NULL);
if (xml == NULL) {
xPathContext, &nodes)) < 0)
goto cleanup;
- if (VIR_ALLOC_N(ret, nodeSize) < 0)
- goto cleanup;
+ ret = g_new0(char *, nodeSize);
for (i = 0; i < nodeSize; i++) {
xmlNodePtr node = nodes[i];
xPathContext,
&nodes)) < 0)
goto cleanup;
- if (VIR_ALLOC_N(ret, nodeSize) < 0)
- goto cleanup;
+ ret = g_new0(char *, nodeSize);
for (i = 0; i < nodeSize; i++) {
xmlNodePtr node = nodes[i];
}
if (hardDisk == NULL)
return 0;
- if (VIR_ALLOC_N(ret, 1) < 0)
- return 0;
+ ret = g_new0(virVBoxSnapshotConfHardDiskPtr, 1);
returnSize = 1;
ret[returnSize - 1] = hardDisk;
virVBoxSnapshotConfHardDiskPtr *tempList = NULL;
virVBoxSnapshotConfHardDiskPtr *diskList = NULL;
- if (VIR_ALLOC_N(diskList, 0) < 0)
- return -1;
+ diskList = g_new0(virVBoxSnapshotConfHardDiskPtr, 0);
for (i = 0; i < machine->mediaRegistry->ndisks; i++) {
tempSize = virVBoxSnapshotConfAllChildren(machine->mediaRegistry->disks[i], &tempList);
virVBoxSnapshotConfHardDiskPtr *tempList = NULL;
virVBoxSnapshotConfHardDiskPtr *diskList = NULL;
- if (VIR_ALLOC_N(diskList, 0) < 0)
- return -1;
+ diskList = g_new0(virVBoxSnapshotConfHardDiskPtr, 0);
for (i = 0; i < machine->mediaRegistry->ndisks; i++) {
tempSize = virVBoxSnapshotConfAllChildren(machine->mediaRegistry->disks[i], &tempList);