commit - d9b6c99dced7ada09d40ee836919391fd28feb14
commit + 427b8b3cf4ce51b92d82969edb99f21197e98d79
blob - 5ea01d9eae6a3c28570a95c7e40b68db0a8f3760
blob + da98e7d7fd329d2fa59d5fc429888c9a6d5307fc
--- arraylist.h
+++ arraylist.h
/* Usage:
*
- * ARRAYLIST(any_type_t) list;
- * // OR
- * typedef ARRAYLIST(any_type_t) any_type_list_t;
- * any_type_list_t list;
+ * ARRAYLIST_HEAD(head_type, any_type) list;
*
- * ARRAYLIST_INIT(list, 128); // < number of (at first unused) members to add on each realloc
- * any_type_t *x;
- * while (bar) {
- * ARRAYLIST_ADD(x, list); // < enlarges the allocated array as needed; list.head may change due to realloc
- * if (!x)
- * abort();
- * *x = random_foo_value;
- * }
+ * // number of (at first unused) members to add on each realloc
+ * ARRAYLIST_INIT(list, 128);
+ *
+ * struct any_type *x;
+ * while (bar) {
+ * // enlarges the allocated array as needed;
+ * // list.head may change due to realloc
+ * ARRAYLIST_ADD(x, list);
+ * if (!x)
+ * abort();
+ * *x = random_foo_value;
+ * }
* for (i = 0; i < list.len; i++)
* printf("%s", foo_to_str(list.head[i]));
* ARRAYLIST_FREE(list);
*/
-#define ARRAYLIST(MEMBER_TYPE) \
- struct { \
- MEMBER_TYPE *head; \
+#define ARRAYLIST_HEAD(LIST_NAME, MEMBER_TYPE) \
+ struct LIST_NAME { \
+ struct MEMBER_TYPE *head; \
unsigned int len; \
unsigned int allocated; \
unsigned int alloc_blocksize; \
blob - a7c97d89d224167214a0a9f44ee7238ed20d205f
blob + c88a63887cb245a60bbcc098d918ccffaad0ce64
--- diff_main.c
+++ diff_main.c
struct diff_atom *right_start, unsigned int right_count)
{
struct diff_chunk *chunk;
- diff_chunk_arraylist_t *result;
+ struct diff_chunk_arraylist *result;
if (solved && !state->temp_result.len)
result = &state->result->chunks;
blob - 3390c1a41b4dd915ef845f47697b12943111ef71
blob + 3bcdfdc2e90685321cb2926b5d44a3ca3ee0e4ac
--- diff_main.h
+++ diff_main.h
struct diff_data {
const uint8_t *data;
size_t len;
- ARRAYLIST(struct diff_atom) atoms;
+ ARRAYLIST_HEAD(, diff_atom) atoms;
struct diff_data *root;
};
unsigned int right_count;
};
-typedef ARRAYLIST(struct diff_chunk) diff_chunk_arraylist_t;
+ARRAYLIST_HEAD(diff_chunk_arraylist, diff_chunk);
#define DIFF_RESULT_ALLOC_BLOCKSIZE 128
struct diff_result {
enum diff_rc rc;
struct diff_data left;
struct diff_data right;
- diff_chunk_arraylist_t chunks;
+ struct diff_chunk_arraylist chunks;
};
struct diff_state {
unsigned int recursion_depth_left;
/* Remaining chunks from one diff algorithm pass, if any solved == false chunks came up. */
- diff_chunk_arraylist_t temp_result;
+ struct diff_chunk_arraylist temp_result;
};
struct diff_chunk *diff_state_add_chunk(struct diff_state *state, bool solved,