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