libroot/posix/stdio: Remove unused portions.
[haiku.git] / src / system / kernel / boot_item.cpp
blob332f266b3e13f1297cb50156a3dd4a569855bc99
1 /*
2 * Copyright 2005-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
7 #include <boot_item.h>
8 #include <util/DoublyLinkedList.h>
9 #include <util/kernel_cpp.h>
11 #include <string.h>
14 // ToDo: the boot items are not supposed to be changed after kernel startup
15 // so no locking is done. So for now, we need to be careful with adding
16 // new items.
18 struct boot_item : public DoublyLinkedListLinkImpl<boot_item> {
19 const char *name;
20 void *data;
21 size_t size;
24 typedef DoublyLinkedList<boot_item> ItemList;
27 static ItemList sItemList;
30 status_t
31 add_boot_item(const char *name, void *data, size_t size)
33 boot_item *item = new(nothrow) boot_item;
34 if (item == NULL)
35 return B_NO_MEMORY;
37 item->name = name;
38 item->data = data;
39 item->size = size;
41 sItemList.Add(item);
42 return B_OK;
46 void *
47 get_boot_item(const char *name, size_t *_size)
49 if (name == NULL || name[0] == '\0')
50 return NULL;
52 // search item
53 for (ItemList::Iterator it = sItemList.GetIterator(); it.HasNext();) {
54 boot_item *item = it.Next();
56 if (!strcmp(name, item->name)) {
57 if (_size != NULL)
58 *_size = item->size;
60 return item->data;
64 return NULL;
68 status_t
69 boot_item_init(void)
71 new(&sItemList) ItemList;
72 // static initializers do not work in the kernel,
73 // so we have to do it here, manually
75 return B_OK;