72#define MK_VECTOR_TYPE(Type, type, ...) \
73typedef struct Type##List { \
74 __VA_ARGS__ ; \
75 uint32_t len; \
76 uint32_t cap; \
77 Type ptr[]; \
78} Type##List; \
79 \
80ANN static inline Type##List *new_##type##list(const MemPool mp, const uint32_t len) { \
81 return (Type##List*)new_mp_vector(mp, Type, len); \
82} \
83ANN static inline void free_##type##list(const MemPool mp, Type##List *v) { \
84 mp_free2(mp, sizeof(Type##List) + (m_uint)(v->cap * sizeof(Type)), v); \
85} \
86ANN static inline void type##list_resize(const MemPool mp, Type##List **ap, \
87 const uint32_t cap) { \
88 return mp_vector_resize(mp, (MP_Vector**)ap, sizeof(Type), cap); \
89} \
90ANN static inline Type type##list_at(const Type##List *v, const uint32_t index) { \
91 return v->ptr[index]; \
92} \
93ANN static inline Type* type##list_ptr_at(Type##List *v, const uint32_t index) { \
94 return v->ptr + index; \
95} \
96ANN static inline void type##list_set(Type##List *v, const uint32_t index, \
97 Type data) { \
98 v->ptr[index] = data; \
99} \
100ANN static inline void type##list_add(const MemPool mp, Type##List **v, \
101 Type data) { \
102 mp_vector_add(mp, (MP_Vector**)v, Type, data); \
103} \
104static inline uint32_t type##list_len(const Type##List *a) { \
105 return a ? a->len : 0; \
106} \
107ANN static inline Type type##list_back(const Type##List *a) { \
108 return a->ptr[a->len-1]; \
109}