fix(memory): realloc must behave like malloc when ptr is nullptr