Commit Diff


commit - 44cf49504c18b4bb2edd3518b6e1192b5e4f4416
commit + 2c8a57df59d1b63727c21ec367fdd2a091392d0c
blob - 844b0c3432c7f119512c6a8f840691ddb9c39689
blob + f8b01eed134fc9c6c5e951a7ac9e05485a653ea7
--- include/diff/arraylist.h
+++ include/diff/arraylist.h
@@ -92,6 +92,15 @@ static inline void *recallocarray(void *buf, size_t ol
 		(ARRAY_LIST).len++; \
 	} while (0)
 
+#define ARRAYLIST_INSERT(NEW_ITEM_P, ARRAY_LIST, AT_IDX) do { \
+		ARRAYLIST_ADD(NEW_ITEM_P, ARRAY_LIST); \
+		if ((AT_IDX) < (ARRAY_LIST).len) \
+			memmove(&(ARRAY_LIST).head[(AT_IDX) + 1], \
+				&(ARRAY_LIST).head[AT_IDX], \
+				((ARRAY_LIST).len - (AT_IDX)) \
+					* sizeof(*(ARRAY_LIST).head)); \
+	} while (0)
+
 #define ARRAYLIST_CLEAR(ARRAY_LIST) \
 	(ARRAY_LIST).len = 0