mergefree (struct dns_transmit *d)
{
    int i = 0;

    if (merge_enable)
        unregister_inprogress (d);

    /* unregister us from our mater */
    if (d->master)
    {
        for (i = 0; i < d->master->nslaves; i++)
            if (d->master->slaves[i] == d)
                d->master->slaves[i] = 0;
    }

    /* and unregister all of our slaves from us */
    for (i = 0; i < d->nslaves; i++)
    {
        if (d->slaves[i])
            d->slaves[i]->master = NULL;
    }

    d->nslaves = 0;
}
mergefree (struct dns_transmit *d)
{
    int i = 0;

    if (merge_enable)
        unregister_inprogress (d);

     
    if (d->master)
    {
        for (i = 0; i < d->master->nslaves; i++)
            if (d->master->slaves[i] == d)
                d->master->slaves[i] = 0;
    }

     
    for (i = 0; i < d->nslaves; i++)
    {
        if (d->slaves[i])
            d->slaves[i]->master = NULL;
    }

    d->nslaves = 0;
}