array.h revision fcb19f9e9933ef693fe98d3925ea52887ea8cd86
#ifndef ARRAY_H
#define ARRAY_H
/* Array is a buffer accessible using fixed size elements. As long as the
compiler provides typeof() function, the array provides type safety. If
a wrong type is tried to be added to the array, or if the array's contents
are tried to be used using a wrong type, the compiler will give a warning.
Example usage:
struct foo {
ARRAY(struct bar) bars;
...
};
i_array_init(&foo->bars, 10);
struct bar *bar = array_idx(&foo->bars, 5);
struct baz *baz = array_idx(&foo->bars, 5); // compiler warning
If you want to pass an array as a parameter to a function, you'll need to
create a type for the array using ARRAY_DEFINE_TYPE() and use the type in
the parameter using ARRAY_TYPE().
Example:
ARRAY_DEFINE_TYPE(foo, struct foo);
void do_foo(ARRAY_TYPE(foo) *bars) {
struct foo *foo = array_idx(bars, 0);
}
*/
#include "array-decl.h"
#include "buffer.h"
#ifdef __GNUC__
# define ARRAY_TYPE_CAST_CONST(array) \
# define ARRAY_TYPE_CAST_MODIFIABLE(array) \
#else
# define ARRAY_TYPE_CAST_CONST(array)
# define ARRAY_TYPE_CAST_MODIFIABLE(array)
#endif
/* usage: struct foo *foo; array_foreach(foo_arr, foo) { .. } */
for (const void *elem ## __foreach_end = \
#else
(elem)++)
(elem)++)
#endif
static inline void
{
}
static inline void
{
}
static inline void
{
}
#define array_free(array) \
static inline bool
{
}
#define array_is_created(array) \
{
}
#define array_get_pool(array) \
static inline void
{
}
#define array_clear(array) \
static inline unsigned int ATTR_PURE
{
}
#define array_count(array) \
static inline void
{
}
static inline void
{
}
static inline void
{
}
static inline void
{
}
static inline const void *
{
}
static inline const void * ATTR_PURE
{
}
static inline void *
{
}
static inline void *
{
void *data;
return data;
}
#define array_append_space(array) \
#define array_append_zero(array) \
static inline void
{
}
#define array_reverse(array) \
(int (*)(const void *, const void *))cmp)
int (*cmp)(const void *, const void *));
#endif