schema CHANGE convert 0-terminated arrays to sized-arrays

Introduce new "sized-arrays" - needed size is the same or smaller as for
0-terminated (terminated by zero pointer, so actually 4-8 bytes). But it
also directly provides number of items in the array.
diff --git a/src/common.h b/src/common.h
index 10631fc..d8ce013 100644
--- a/src/common.h
+++ b/src/common.h
@@ -262,17 +262,21 @@
 LY_ERR lysp_check_date(struct ly_ctx *ctx, const char *date, int date_len, const char *stmt);
 
 /*
- * Macros to work with 0-terminated arrays.
+ * Macros to work with sized-arrays.
  *
- * There is a NULL pointer allocated after the last item to terminate the array.
+ * There is a 32b unsigned size (number of items) of the array at its beginning.
+ *
  */
-#define LYSP_ARRAY_NEW_RET(CTX, ARRAY, NEW_ITEM, RETVAL) int _count; \
-        for (_count = 0; *(ARRAY) && *((void **)(*(ARRAY) + _count)); ++_count); \
-        if (!_count) *(ARRAY) = malloc(sizeof **(ARRAY) + sizeof(void *)); \
-            else *(ARRAY) = ly_realloc(*(ARRAY), (_count + 1) * sizeof **(ARRAY) + sizeof(void *)); \
-        LY_CHECK_ERR_RET(!*(ARRAY), LOGMEM(CTX), RETVAL); \
-        *((void **)(*(ARRAY) + _count + 1)) = NULL; \
-        (NEW_ITEM) = (*(ARRAY)) + _count; \
+#define LYSP_ARRAY_NEW_RET(CTX, ARRAY, NEW_ITEM, RETVAL) \
+        if (!(ARRAY)) { \
+            ARRAY = malloc(sizeof(uint32_t) + sizeof *(ARRAY)); \
+            *((uint32_t*)(ARRAY)) = 1; \
+        } else { \
+            ++(*((uint32_t*)(ARRAY))); \
+            ARRAY = ly_realloc(ARRAY, sizeof(uint32_t) + (*((uint32_t*)(ARRAY)) * sizeof *(ARRAY))); \
+            LY_CHECK_ERR_RET(!(ARRAY), LOGMEM(CTX), RETVAL); \
+        } \
+        (NEW_ITEM) = (void*)((uint32_t*)((ARRAY) + *((uint32_t*)(ARRAY)) - 1) + 1); \
         memset(NEW_ITEM, 0, sizeof *(NEW_ITEM));
 
 #endif /* LY_COMMON_H_ */