c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen#ifndef ARRAY_DECL_H
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen#define ARRAY_DECL_H
16f816d3f3c32ae3351834253f52ddd0212bcbf3Timo Sirainen
4ee00532a265bdfb38539d811fcd12d51210ac35Timo Sirainen#define ARRAY(array_type) union { struct array arr; array_type const *const *v; array_type **v_modifiable; }
36f614569bbff9a10717c9362b070ded8836f973Phil Carmody#define ARRAY_INIT { { NULL, 0 } }
16f816d3f3c32ae3351834253f52ddd0212bcbf3Timo Sirainen
8d80659e504ffb34bb0c6a633184fece35751b18Timo Sirainen#define ARRAY_DEFINE_TYPE(name, array_type) \
c848d8976d0a5e92a406d0e4a9f0b6f46d9eefd8Timo Sirainen union array ## __ ## name { struct array arr; array_type const *const *v; array_type **v_modifiable; }
8d80659e504ffb34bb0c6a633184fece35751b18Timo Sirainen#define ARRAY_TYPE(name) \
8d80659e504ffb34bb0c6a633184fece35751b18Timo Sirainen union array ## __ ## name
16f816d3f3c32ae3351834253f52ddd0212bcbf3Timo Sirainen
16f816d3f3c32ae3351834253f52ddd0212bcbf3Timo Sirainenstruct array {
16f816d3f3c32ae3351834253f52ddd0212bcbf3Timo Sirainen buffer_t *buffer;
16f816d3f3c32ae3351834253f52ddd0212bcbf3Timo Sirainen size_t element_size;
16f816d3f3c32ae3351834253f52ddd0212bcbf3Timo Sirainen};
16f816d3f3c32ae3351834253f52ddd0212bcbf3Timo Sirainen
669c130b3414685799e28e702ae3e68f30c46e04Timo SirainenARRAY_DEFINE_TYPE(string, char *);
d3ffe3cb44471c88f483d7c9075336b9b264bb6cTimo SirainenARRAY_DEFINE_TYPE(const_string, const char *);
6525f63717c08f29648fe3dd8c940c915db47d10Timo SirainenARRAY_DEFINE_TYPE(uint8_t, uint8_t);
6525f63717c08f29648fe3dd8c940c915db47d10Timo SirainenARRAY_DEFINE_TYPE(uint16_t, uint16_t);
c740209eb3db031022c6fd436fa2ef1aa0ec46b8Timo SirainenARRAY_DEFINE_TYPE(uint32_t, uint32_t);
6525f63717c08f29648fe3dd8c940c915db47d10Timo SirainenARRAY_DEFINE_TYPE(uint64_t, uint64_t);
6c24d1c9aaf3b578ac5261a0f6a898ef8fc26f65Timo SirainenARRAY_DEFINE_TYPE(uint, unsigned int);
a64adf62fa33f2463a86f990217b0c9078531a40Timo SirainenARRAY_DEFINE_TYPE(void_array, void *);
d3ffe3cb44471c88f483d7c9075336b9b264bb6cTimo Sirainen
16f816d3f3c32ae3351834253f52ddd0212bcbf3Timo Sirainen#endif