Added conditions to handle realloc requests the way libc realloc would handle