7 static inline void **stm_array_clone_insert(void **old_array
, int old_count
, int index
, void *data
)
9 size_t ps
= sizeof(void *);
12 void **new_array
= malloc(ps
* (old_count
+ 1));
13 memcpy(&new_array
[0], &old_array
[0], ps
* index
);
14 new_array
[index
] = data
;
15 if (index
!= old_count
)
16 memcpy(&new_array
[index
+ 1], &old_array
[index
], ps
* (old_count
- index
));
20 static inline void **stm_array_clone_remove(void **old_array
, int old_count
, int index
)
22 size_t ps
= sizeof(void *);
25 void **new_array
= malloc(ps
* (old_count
- 1));
26 memcpy(&new_array
[0], &old_array
[0], ps
* index
);
27 memcpy(&new_array
[index
], &old_array
[index
+ 1], ps
* (old_count
- index
- 1));
31 #define STM_ARRAY_FREE(old_array, count, destructor) \
32 for (int i = 0; i < (count); i++) \
33 destructor((old_array)[i]); \
36 #define STM_ARRAY_FREE_OBJS(old_array, count) \
38 for (int i = 0; i < (count); i++) \
39 cbox_object_destroy(&(old_array)[i]->_obj_hdr); \