3rdparty/licenseReport: Add seperate LGPL checks
[haiku.git] / src / add-ons / media / media-add-ons / mixer / RtList.h
blob9ad1889d1a5835603f9a9b226d9aa974ad740ac1
1 /*
2 * Copyright 2003 Marcus Overhagen
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _MEDIA_RT_LIST_H
6 #define _MEDIA_RT_LIST_H
9 /*! A simple list template that uses realtime
10 memory and does no error checking. Since
11 it doesn't call constructors or destructors,
12 don't use it to store objects.
14 // TODO: no error checking? Great.
18 #include <RealtimeAlloc.h>
21 template<class value> class RtList {
22 public:
23 RtList()
25 item_max(INIT_COUNT),
26 item_count(0),
27 items((value*)rtm_alloc(NULL, sizeof(value) * INIT_COUNT))
31 ~RtList()
33 rtm_free(items);
36 value* Create()
38 if (item_count == item_max) {
39 item_max += INC_COUNT;
40 rtm_realloc((void**)&items, sizeof(value) * item_max);
42 return &items[item_count++];
45 value* ItemAt(int index)
47 return &items[index];
50 int CountItems()
52 return item_count;
55 void MakeEmpty()
57 item_count = 0;
60 private:
61 RtList(const RtList<value>& other);
62 RtList<value> &operator=(const RtList<value>& other);
64 private:
65 enum { INIT_COUNT = 8, INC_COUNT = 16 };
67 int item_max;
68 int item_count;
69 value* items;
72 #endif // _MEDIA_RT_LIST_H