static void finish(AvahiSAddressResolver *r, AvahiResolverEvent event) {
    assert(r);

    if (r->time_event) {
        avahi_time_event_free(r->time_event);
        r->time_event = NULL;
    }

    switch (event) {
        case AVAHI_RESOLVER_FAILURE:
            r->callback(r, r->interface, r->protocol, event, &r->address, NULL, r->flags, r->userdata);
            break;

        case AVAHI_RESOLVER_FOUND:
            assert(r->ptr_record);
            r->callback(r, r->interface, r->protocol, event, &r->address, r->ptr_record->data.ptr.name, r->flags, r->userdata);
            break;
    }
}
static void finish(AvahiSAddressResolver *r, AvahiResolverEvent event) {
    assert(r);

    if (r->time_event) {
        avahi_time_event_free(r->time_event);
        r->time_event = NULL;
    }

    switch (event) {
        case AVAHI_RESOLVER_FAILURE:
            r->callback(r, r->interface, r->protocol, event, &r->address, NULL, r->flags, r->userdata);
            break;

        case AVAHI_RESOLVER_FOUND:
            assert(r->ptr_record);
            r->callback(r, r->interface, r->protocol, event, &r->address, r->ptr_record->data.ptr.name, r->flags, r->userdata);
            break;
    }
}