realloc array only when pointer is non-null
related to #9