int
ACE_Service_Repository::relocate_i (size_t begin,
                                    size_t end,
                                    const ACE_DLL& adll)
{
    ACE_SHLIB_HANDLE new_handle = adll.get_handle (0);

    for (size_t i = begin; i < end; i++)
    {
        ACE_Service_Type *type =
            const_cast<ACE_Service_Type *> (this->service_vector_[i]);

        ACE_SHLIB_HANDLE old_handle = (type == 0) ? ACE_SHLIB_INVALID_HANDLE
                                      : type->dll ().get_handle (0);

#ifndef ACE_NLOGGING
        if (ACE::debug ())
        {
            if (type == 0)
                ACE_DEBUG ((LM_DEBUG,
                            ACE_TEXT ("ACE (%P|%t) SR::relocate_i - repo=%@ [%d] (size=%d)")
                            ACE_TEXT (": skipping empty slot\n"),
                            this,
                            i,
                            this->total_size_));
            else
                ACE_DEBUG ((LM_DEBUG,
                            ACE_TEXT ("ACE (%P|%t) SR::relocate_i - repo=%@ [%d] (size=%d)")
                            ACE_TEXT (": trying name=%s, handle: %d -> %d\n"),
                            this,
                            i,
                            this->total_size_,
                            type->name (),
                            old_handle,
                            new_handle));
        }
#endif

        if (type != 0  // skip any gaps
                && old_handle == ACE_SHLIB_INVALID_HANDLE
                && new_handle != old_handle)
        {
#ifndef ACE_NLOGGING
            if (ACE::debug ())
                ACE_DEBUG ((LM_DEBUG,
                            ACE_TEXT ("ACE (%P|%t) SR::relocate_i - repo=%@ [%d] (size=%d)")
                            ACE_TEXT (": relocating name=%s, handle: %d -> %d\n"),
                            this,
                            i,
                            this->total_size_,
                            type->name (),
                            old_handle,
                            new_handle));
#endif
            type->dll (adll); // ups the refcount on adll
        }
    }

    return 0;
}