CHECK_PTR macro to check pointer