strict aliasing of sized arrays (#1086)

common BUGFIX strict aliasing of sized arrays

The sized array is commonly used for storing an array of pointers or other
structures. Each sized array is preceded by a counter providing the
size of the array. Since we used uint32_t type for the counter, pointers
were misaligned on 64b architectures.

Currently, I don't have any performance measurement, but the sized
arrays are supposed to be used quite intensively in libyang2 and the
strict aliasing could have an impact on the performance. The cost is the
increased size of each array by 4 additional bytes.

The patch changes all the macros working with the counter to use a
generic LY_ARRAY_SIZE_TYPE. For now, it is set to be uint64_t. In the 
future it is possible to simply change the type according to the detected
architecture in build time if such a mechanism will make sense.

Fixes #1044
diff --git a/src/tree_schema_compile.c b/src/tree_schema_compile.c
index f440663..7a76a17 100644
--- a/src/tree_schema_compile.c
+++ b/src/tree_schema_compile.c
@@ -3098,9 +3098,8 @@
                 if (un->types[u + additional]->basetype == LY_TYPE_UNION) {
                     /* add space for additional types from the union subtype */
                     un_aux = (struct lysc_type_union *)un->types[u + additional];
-                    p = ly_realloc(((uint32_t*)(un->types) - 1), sizeof(uint32_t) + ((LY_ARRAY_SIZE(type_p->types) + additional + LY_ARRAY_SIZE(un_aux->types) - 1) * sizeof *(un->types)));
-                    LY_CHECK_ERR_RET(!p, LOGMEM(ctx->ctx);lysc_type_free(ctx->ctx, (struct lysc_type*)un_aux), LY_EMEM);
-                    un->types = (void*)((uint32_t*)(p) + 1);
+                    LY_ARRAY_RESIZE_ERR_RET(ctx->ctx, un->types, (*((uint64_t*)(type_p->types) - 1)) + additional + LY_ARRAY_SIZE(un_aux->types) - 1,
+                                            lysc_type_free(ctx->ctx, (struct lysc_type*)un_aux), LY_EMEM);
 
                     /* copy subtypes of the subtype union */
                     for (v = 0; v < LY_ARRAY_SIZE(un_aux->types); ++v) {