| @@ -20,28 +20,26 @@ | | | @@ -20,28 +20,26 @@ |
20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
27 | * POSSIBILITY OF SUCH DAMAGE. | | 27 | * POSSIBILITY OF SUCH DAMAGE. |
28 | */ | | 28 | */ |
29 | | | 29 | |
30 | #ifndef ARRAY_H | | 30 | #ifndef ARRAY_H |
31 | #define ARRAY_H | | 31 | #define ARRAY_H |
32 | | | 32 | |
33 | #include "inlinedefs.h" | | | |
34 | | | | |
35 | #define ARRAYS_CHECKED | | 33 | #define ARRAYS_CHECKED |
36 | | | 34 | |
37 | #ifdef ARRAYS_CHECKED | | 35 | #ifdef ARRAYS_CHECKED |
38 | #include <assert.h> | | 36 | #include <assert.h> |
39 | #define arrayassert assert | | 37 | #define arrayassert assert |
40 | #else | | 38 | #else |
41 | #define arrayassert(x) ((void)(x)) | | 39 | #define arrayassert(x) ((void)(x)) |
42 | #endif | | 40 | #endif |
43 | | | 41 | |
44 | //////////////////////////////////////////////////////////// | | 42 | //////////////////////////////////////////////////////////// |
45 | // type and base operations | | 43 | // type and base operations |
46 | | | 44 | |
47 | struct array { | | 45 | struct array { |
| @@ -55,27 +53,27 @@ void array_init(struct array *); | | | @@ -55,27 +53,27 @@ void array_init(struct array *); |
55 | void array_cleanup(struct array *); | | 53 | void array_cleanup(struct array *); |
56 | unsigned array_num(const struct array *); | | 54 | unsigned array_num(const struct array *); |
57 | void *array_get(const struct array *, unsigned index_); | | 55 | void *array_get(const struct array *, unsigned index_); |
58 | void array_set(const struct array *, unsigned index_, void *val); | | 56 | void array_set(const struct array *, unsigned index_, void *val); |
59 | int array_setsize(struct array *, unsigned num); | | 57 | int array_setsize(struct array *, unsigned num); |
60 | int array_add(struct array *, void *val, unsigned *index_ret); | | 58 | int array_add(struct array *, void *val, unsigned *index_ret); |
61 | int array_insert(struct array *a, unsigned index_); | | 59 | int array_insert(struct array *a, unsigned index_); |
62 | void array_remove(struct array *a, unsigned index_); | | 60 | void array_remove(struct array *a, unsigned index_); |
63 | | | 61 | |
64 | //////////////////////////////////////////////////////////// | | 62 | //////////////////////////////////////////////////////////// |
65 | // inlining for base operations | | 63 | // inlining for base operations |
66 | | | 64 | |
67 | #ifndef ARRAYINLINE | | 65 | #ifndef ARRAYINLINE |
68 | #define ARRAYINLINE INLINE | | 66 | #define ARRAYINLINE __c99inline |
69 | #endif | | 67 | #endif |
70 | | | 68 | |
71 | ARRAYINLINE unsigned | | 69 | ARRAYINLINE unsigned |
72 | array_num(const struct array *a) | | 70 | array_num(const struct array *a) |
73 | { | | 71 | { |
74 | return a->num; | | 72 | return a->num; |
75 | } | | 73 | } |
76 | | | 74 | |
77 | ARRAYINLINE void * | | 75 | ARRAYINLINE void * |
78 | array_get(const struct array *a, unsigned index_) | | 76 | array_get(const struct array *a, unsigned index_) |
79 | { | | 77 | { |
80 | arrayassert(index_ < a->num); | | 78 | arrayassert(index_ < a->num); |
81 | return a->v[index_]; | | 79 | return a->v[index_]; |