common NEW ly_realloc() and macro for new lysp structure array item
diff --git a/src/common.c b/src/common.c
new file mode 100644
index 0000000..ab47b65
--- /dev/null
+++ b/src/common.c
@@ -0,0 +1,28 @@
+/**
+ * @file common.c
+ * @author Michal Vasko <mvasko@cesnet.cz>
+ * @brief common internal definitions for libyang
+ *
+ * Copyright (c) 2018 CESNET, z.s.p.o.
+ *
+ * This source code is licensed under BSD 3-Clause License (the "License").
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     https://opensource.org/licenses/BSD-3-Clause
+ */
+
+#include <stdlib.h>
+
+void *
+ly_realloc(void *ptr, size_t size)
+{
+    void *new_mem;
+
+    new_mem = realloc(ptr, size);
+    if (!new_mem) {
+        free(ptr);
+    }
+
+    return new_mem;
+}