1/*
2 * Copyright 2007, Ingo Weinhold, bonefish@users.sf.net.
3 * Distributed under the terms of the MIT License.
4 */
5
6#include <new>
7
8#include <List.h>
9
10#include <AutoDeleter.h>
11
12#include "ExtendedPartitionAddOn.h"
13#include "PartitionMapAddOn.h"
14
15
16using std::nothrow;
17
18
19// get_disk_system_add_ons
20status_t
21get_disk_system_add_ons(BList* addOns)
22{
23	PartitionMapAddOn* partitionMapAddOn = new(nothrow) PartitionMapAddOn;
24	ExtendedPartitionAddOn* extendedPartitionAddOn
25		= new(nothrow) ExtendedPartitionAddOn;
26
27	ObjectDeleter<PartitionMapAddOn> mapAddOnDeleter(partitionMapAddOn);
28	ObjectDeleter<ExtendedPartitionAddOn> extendedAddOnDeleter(
29		extendedPartitionAddOn);
30
31	BList list;
32	if (!partitionMapAddOn || !extendedPartitionAddOn
33		|| !list.AddItem(partitionMapAddOn)
34		|| !list.AddItem(extendedPartitionAddOn)
35		|| !addOns->AddList(&list)) {
36		return B_NO_MEMORY;
37	}
38
39	mapAddOnDeleter.Detach();
40	extendedAddOnDeleter.Detach();
41
42	return B_OK;
43}
44