This file is part of GNUnet.
Copyright (C)
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
+ Affero General Public License for more details.
*/
/**
View_remove_peer (const struct GNUNET_PeerIdentity *peer)
{
uint32_t *index;
- uint32_t *index_swap;
+ uint32_t *swap_index;
+ uint32_t last_index;
if (GNUNET_NO == View_contains_peer (peer))
{
}
index = GNUNET_CONTAINER_multipeermap_get (mpm, peer);
GNUNET_assert (NULL != index);
- if (*index < (View_size () - 1) )
+ last_index = View_size () - 1;
+ if (*index < last_index)
{ /* Fill the 'gap' in the array with the last peer */
- array[*index] = array[(View_size () - 1)];
- index_swap = GNUNET_CONTAINER_multipeermap_get (mpm, &array[View_size ()]);
- *index_swap = *index;
+ array[*index] = array[last_index];
+ GNUNET_assert (GNUNET_YES == View_contains_peer (&array[last_index]));
+ swap_index = GNUNET_CONTAINER_multipeermap_get (mpm, &array[last_index]);
+ GNUNET_assert (NULL != swap_index);
+ *swap_index = *index;
GNUNET_free (index);
}
GNUNET_CONTAINER_multipeermap_remove_all (mpm, peer);