6 Copyright (C) 2000-2003 Kern Sibbald and John Walker
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of
11 the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public
19 License along with this program; if not, write to the Free
20 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
23 Kern Sibbald, June MMIII
27 /* Second arg of init */
29 owned_by_alist = true,
30 not_owned_by_alist = false
35 * Array list -- much like a simplified STL vector
36 * array of pointers to inserted items
45 alist(int num = 1, bool own=true);
46 void init(int num = 1, bool own=true);
47 void append(void *item);
49 void * operator [](int index) const;
53 void * operator new(size_t);
54 void operator delete(void *);
57 inline void * alist::operator [](int index) const {
58 if (index < 0 || index >= num_items) {
65 * This allows us to do explicit initialization,
66 * allowing us to mix C++ classes inside malloc'ed
67 * C structures. Define before called in constructor.
69 inline void alist::init(int num, bool own) {
78 inline alist::alist(int num, bool own) {
84 /* Current size of list */
85 inline int alist::size()
90 /* How much to grow by each time */
91 inline void alist::grow(int num)
96 inline void * alist::operator new(size_t)
98 return malloc(sizeof(alist));
101 inline void alist::operator delete(void *item)
103 ((alist *)item)->destroy();