Use memmove instead of writing your own because sunos doesn't support it.
Use calloc instead of reallocarray in tree_init()