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