src/or/consdiff.c
static smartlist_slice_t *
smartlist_slice(smartlist_t *list, int start, int end)
{
  int list_len = smartlist_len(list);
  tor_assert(start >= 0);
  tor_assert(start <= list_len);
  if (end == -1) {
    end = list_len;
  }
  tor_assert(start <= end);

  smartlist_slice_t *slice = tor_malloc(sizeof(smartlist_slice_t));
  slice->list = list;
  slice->offset = start;
  slice->len = end - start;
  return slice;
}
/** Create (allocate) a new slice from a smartlist. Assumes that the start
 * and the end indexes are within the bounds of the initial smartlist. The end
 * element is not part of the resulting slice. If end is -1, the slice is to
 * reach the end of the smartlist.
 */
Create (allocate) a new slice from a smartlist. Assumes that the start
and the end indexes are within the bounds of the initial smartlist. The end
element is not part of the resulting slice. If end is -1, the slice is to
reach the end of the smartlist.
Create ( allocate ) a new slice from a smartlist . Assumes that the start and the end indexes are within the bounds of the initial smartlist . The end element is not part of the resulting slice . If end is - 1 the slice is to reach the end of the smartlist .
static smartlist_slice_t *
smartlist_slice(smartlist_t *list, int start, int end)
{
  int list_len = smartlist_len(list);
  tor_assert(start >= 0);
  tor_assert(start <= list_len);
  if (end == -1) {
    end = list_len;
  }
  tor_assert(start <= end);
  smartlist_slice_t *slice = tor_malloc(sizeof(smartlist_slice_t));
  slice->list = list;
  slice->offset = start;
  slice->len = end - start;
  return slice;
}
static smartlist_slice_t * smartlist_slice ( smartlist_t * list , int start , int end ) { int list_len = smartlist_len ( list ) ; tor_assert ( start >= 0 ) ; tor_assert ( start <= list_len ) ; if ( end == -1 ) { end = list_len ; } tor_assert ( start <= end ) ; smartlist_slice_t * slice = tor_malloc ( sizeof ( smartlist_slice_t ) ) ; slice -> list = list ; slice -> offset = start ; slice -> len = end - start ; return slice ; }
Create (allocate) a new slice from a smartlist.
Create ( allocate ) a new slice from a smartlist .