Coverage report for dbus/dbus-list.c.gcov

        -:    0:Source:dbus-list.c
        -:    0:Graph:.libs/dbus-list.gcno
        -:    0:Data:.libs/dbus-list.gcda
        -:    0:Runs:11815
        -:    0:Programs:5
        -:    1:/* -*- mode: C; c-file-style: "gnu" -*- */
        -:    2:/* dbus-list.c Generic linked list utility (internal to D-BUS implementation)
        -:    3: * 
        -:    4: * Copyright (C) 2002  Red Hat, Inc.
        -:    5: *
        -:    6: * Licensed under the Academic Free License version 2.1
        -:    7: * 
        -:    8: * This program is free software; you can redistribute it and/or modify
        -:    9: * it under the terms of the GNU General Public License as published by
        -:   10: * the Free Software Foundation; either version 2 of the License, or
        -:   11: * (at your option) any later version.
        -:   12: *
        -:   13: * This program is distributed in the hope that it will be useful,
        -:   14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
        -:   15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        -:   16: * GNU General Public License for more details.
        -:   17: * 
        -:   18: * You should have received a copy of the GNU General Public License
        -:   19: * along with this program; if not, write to the Free Software
        -:   20: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
        -:   21: *
        -:   22: */
        -:   23:
        -:   24:#include "dbus-internals.h"
        -:   25:#include "dbus-list.h"
        -:   26:#include "dbus-mempool.h"
        -:   27:#include "dbus-threads-internal.h"
        -:   28:
        -:   29:/**
        -:   30: * @defgroup DBusList Linked list
        -:   31: * @ingroup  DBusInternals
        -:   32: * @brief DBusList data structure
        -:   33: *
        -:   34: * Types and functions related to DBusList.
        -:   35: */
        -:   36:
        -:   37:static DBusMemPool *list_pool;
        -:   38:_DBUS_DEFINE_GLOBAL_LOCK (list);
        -:   39:
        -:   40:/**
        -:   41: * @defgroup DBusListInternals Linked list implementation details
        -:   42: * @ingroup  DBusInternals
        -:   43: * @brief DBusList implementation details
        -:   44: *
        -:   45: * The guts of DBusList.
        -:   46: *
        -:   47: * @{
        -:   48: */
        -:   49:
        -:   50:/* the mem pool is probably a speed hit, with the thread
        -:   51: * lock, though it does still save memory - unknown.
        -:   52: */
        -:   53:static DBusList*
        -:   54:alloc_link (void *data)
function alloc_link called 3090500 returned 100% blocks executed 95%
  3090500:   55:{
        -:   56:  DBusList *link;
        -:   57:
  3090500:   58:  if (!_DBUS_LOCK (list))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####:   59:    return NULL;
        -:   60:
  3090500:   61:  if (list_pool == NULL)
branch  0 taken 47% (fallthrough)
branch  1 taken 53%
        -:   62:    {      
  1463484:   63:      list_pool = _dbus_mem_pool_new (sizeof (DBusList), TRUE);
call    0 returned 100%
        -:   64:
  1463484:   65:      if (list_pool == NULL)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        -:   66:        {
       21:   67:          _DBUS_UNLOCK (list);
call    0 returned 100%
       21:   68:          return NULL;
        -:   69:        }
        -:   70:
  1463463:   71:      link = _dbus_mem_pool_alloc (list_pool);
call    0 returned 100%
  1463463:   72:      if (link == NULL)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        -:   73:        {
       21:   74:          _dbus_mem_pool_free (list_pool);
call    0 returned 100%
       21:   75:          list_pool = NULL;
       21:   76:          _DBUS_UNLOCK (list);
call    0 returned 100%
       21:   77:          return NULL;
        -:   78:        }
        -:   79:    }
        -:   80:  else
        -:   81:    {
  1627016:   82:      link = _dbus_mem_pool_alloc (list_pool);
call    0 returned 100%
        -:   83:    }
        -:   84:
  3090458:   85:  if (link)
branch  0 taken 99% (fallthrough)
branch  1 taken 1%
  3083317:   86:    link->data = data;
        -:   87:  
  3090458:   88:  _DBUS_UNLOCK (list);
call    0 returned 100%
        -:   89:
  3090458:   90:  return link;
        -:   91:}
        -:   92:
        -:   93:static void
        -:   94:free_link (DBusList *link)
function free_link called 3078735 returned 100% blocks executed 100%
  3078735:   95:{  
  3078735:   96:  _DBUS_LOCK (list);
call    0 returned 100%
  3078735:   97:  if (_dbus_mem_pool_dealloc (list_pool, link))
call    0 returned 100%
branch  1 taken 48% (fallthrough)
branch  2 taken 52%
        -:   98:    {
  1463024:   99:      _dbus_mem_pool_free (list_pool);
call    0 returned 100%
  1463024:  100:      list_pool = NULL;
        -:  101:    }
        -:  102:  
  3078735:  103:  _DBUS_UNLOCK (list);
call    0 returned 100%
  3078735:  104:}
        -:  105:
        -:  106:static void
        -:  107:link_before (DBusList **list,
        -:  108:             DBusList  *before_this_link,
        -:  109:             DBusList  *link)
function link_before called 3389707 returned 100% blocks executed 100%
  3389707:  110:{
  3389707:  111:  if (*list == NULL)
branch  0 taken 89% (fallthrough)
branch  1 taken 11%
        -:  112:    {
  3011141:  113:      link->prev = link;
  3011141:  114:      link->next = link;
  3011141:  115:      *list = link;
        -:  116:    }
        -:  117:  else
        -:  118:    {      
   378566:  119:      link->next = before_this_link;
   378566:  120:      link->prev = before_this_link->prev;
   378566:  121:      before_this_link->prev = link;
   378566:  122:      link->prev->next = link;
        -:  123:      
   378566:  124:      if (before_this_link == *list)
branch  0 taken 99% (fallthrough)
branch  1 taken 1%
   378565:  125:        *list = link;
        -:  126:    }
  3389707:  127:}
        -:  128:
        -:  129:static void
        -:  130:link_after (DBusList **list,
        -:  131:            DBusList  *after_this_link,
        -:  132:            DBusList  *link)
function link_after called 2 returned 100% blocks executed 75%
        2:  133:{
        2:  134:  if (*list == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -:  135:    {
    #####:  136:      link->prev = link;
    #####:  137:      link->next = link;
    #####:  138:      *list = link;
        -:  139:    }
        -:  140:  else
        -:  141:    {
        2:  142:      link->prev = after_this_link;
        2:  143:      link->next = after_this_link->next;
        2:  144:      after_this_link->next = link;
        2:  145:      link->next->prev = link;
        -:  146:    }
        2:  147:}
        -:  148:
        -:  149:/** @} */
        -:  150:
        -:  151:/**
        -:  152: * @addtogroup DBusList
        -:  153: * @{
        -:  154: */
        -:  155:
        -:  156:/**
        -:  157: * @struct DBusList
        -:  158: *
        -:  159: * A node in a linked list.
        -:  160: *
        -:  161: * DBusList is a circular list; that is, the tail of the list
        -:  162: * points back to the head of the list. The empty list is
        -:  163: * represented by a #NULL pointer.
        -:  164: */
        -:  165:
        -:  166:/**
        -:  167: * @def _dbus_list_get_next_link
        -:  168: *
        -:  169: * Gets the next link in the list, or #NULL if
        -:  170: * there are no more links. Used for iteration.
        -:  171: *
        -:  172: * @code
        -:  173: * DBusList *link;
        -:  174: * link = _dbus_list_get_first_link (&list);
        -:  175: * while (link != NULL)
        -:  176: *   {
        -:  177: *     printf ("value is %p\n", link->data);
        -:  178: *     link = _dbus_list_get_next_link (&link);
        -:  179: *   }
        -:  180: * @endcode
        -:  181: *
        -:  182: * @param list address of the list head.
        -:  183: * @param link current link.
        -:  184: * @returns the next link, or %NULL if none.
        -:  185: * 
        -:  186: */
        -:  187:
        -:  188:/**
        -:  189: * @def _dbus_list_get_prev_link
        -:  190: *
        -:  191: * Gets the previous link in the list, or #NULL if
        -:  192: * there are no more links. Used for iteration.
        -:  193: *
        -:  194: * @code
        -:  195: * DBusList *link;
        -:  196: * link = _dbus_list_get_last_link (&list);
        -:  197: * while (link != NULL)
        -:  198: *   {
        -:  199: *     printf ("value is %p\n", link->data);
        -:  200: *     link = _dbus_list_get_prev_link (&link);
        -:  201: *   }
        -:  202: * @endcode
        -:  203: *
        -:  204: * @param list address of the list head.
        -:  205: * @param link current link.
        -:  206: * @returns the previous link, or %NULL if none.
        -:  207: * 
        -:  208: */
        -:  209:
        -:  210:/**
        -:  211: * Allocates a linked list node. Useful for preallocating
        -:  212: * nodes and using _dbus_list_append_link() to avoid
        -:  213: * allocations.
        -:  214: * 
        -:  215: * @param data the value to store in the link.
        -:  216: * @returns a newly allocated link.
        -:  217: */
        -:  218:DBusList*
        -:  219:_dbus_list_alloc_link (void *data)
function _dbus_list_alloc_link called 173386 returned 100% blocks executed 100%
   173386:  220:{
   173386:  221:  return alloc_link (data);
call    0 returned 100%
        -:  222:}
        -:  223:
        -:  224:/**
        -:  225: * Frees a linked list node allocated with _dbus_list_alloc_link.
        -:  226: * Does not free the data in the node.
        -:  227: *
        -:  228: * @param link the list node
        -:  229: */
        -:  230:void
        -:  231:_dbus_list_free_link (DBusList *link)
function _dbus_list_free_link called 198612 returned 100% blocks executed 100%
   198612:  232:{
   198612:  233:  free_link (link);
call    0 returned 100%
   198612:  234:}
        -:  235:
        -:  236:
        -:  237:/**
        -:  238: * Appends a value to the list. May return #FALSE
        -:  239: * if insufficient memory exists to add a list link.
        -:  240: * This is a constant-time operation.
        -:  241: *
        -:  242: * @param list address of the list head.
        -:  243: * @param data the value to append.
        -:  244: * @returns #TRUE on success.
        -:  245: */
        -:  246:dbus_bool_t
        -:  247:_dbus_list_append (DBusList **list,
        -:  248:                   void      *data)
function _dbus_list_append called 2785194 returned 100% blocks executed 100%
  2785194:  249:{
  2785194:  250:  if (!_dbus_list_prepend (list, data))
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
     6602:  251:    return FALSE;
        -:  252:
        -:  253:  /* Now cycle the list forward one so the prepended node is the tail */
  2778592:  254:  *list = (*list)->next;
        -:  255:
  2778592:  256:  return TRUE;
        -:  257:}
        -:  258:
        -:  259:/**
        -:  260: * Prepends a value to the list. May return #FALSE
        -:  261: * if insufficient memory exists to add a list link.
        -:  262: * This is a constant-time operation.
        -:  263: *
        -:  264: * @param list address of the list head.
        -:  265: * @param data the value to prepend.
        -:  266: * @returns #TRUE on success.
        -:  267: */
        -:  268:dbus_bool_t
        -:  269:_dbus_list_prepend (DBusList **list,
        -:  270:                    void      *data)
function _dbus_list_prepend called 2917110 returned 100% blocks executed 100%
  2917110:  271:{
        -:  272:  DBusList *link;
        -:  273:
  2917110:  274:  link = alloc_link (data);
call    0 returned 100%
  2917110:  275:  if (link == NULL)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
     6842:  276:    return FALSE;
        -:  277:
  2910268:  278:  link_before (list, *list, link);
call    0 returned 100%
        -:  279:
  2910268:  280:  return TRUE;
        -:  281:}
        -:  282:
        -:  283:/**
        -:  284: * Appends a link to the list.
        -:  285: * Cannot fail due to out of memory.
        -:  286: * This is a constant-time operation.
        -:  287: *
        -:  288: * @param list address of the list head.
        -:  289: * @param link the link to append.
        -:  290: */
        -:  291:void
        -:  292:_dbus_list_append_link (DBusList **list,
        -:  293:			DBusList *link)
function _dbus_list_append_link called 252357 returned 100% blocks executed 100%
   252357:  294:{
   252357:  295:  _dbus_list_prepend_link (list, link);
call    0 returned 100%
        -:  296:
        -:  297:  /* Now cycle the list forward one so the prepended node is the tail */
   252357:  298:  *list = (*list)->next;
   252357:  299:}
        -:  300:
        -:  301:/**
        -:  302: * Prepends a link to the list. 
        -:  303: * Cannot fail due to out of memory.
        -:  304: * This is a constant-time operation.
        -:  305: *
        -:  306: * @param list address of the list head.
        -:  307: * @param link the link to prepend.
        -:  308: */
        -:  309:void
        -:  310:_dbus_list_prepend_link (DBusList **list,
        -:  311:			 DBusList *link)
function _dbus_list_prepend_link called 479437 returned 100% blocks executed 100%
   479437:  312:{
   479437:  313:  link_before (list, *list, link);
call    0 returned 100%
   479437:  314:}
        -:  315:
        -:  316:#ifdef DBUS_BUILD_TESTS
        -:  317:/**
        -:  318: * Inserts data into the list before the given existing link.
        -:  319: * 
        -:  320: * @param list the list to modify
        -:  321: * @param before_this_link existing link to insert before, or #NULL to append
        -:  322: * @param data the value to insert
        -:  323: * @returns #TRUE on success, #FALSE if memory allocation fails
        -:  324: */
        -:  325:dbus_bool_t
        -:  326:_dbus_list_insert_before (DBusList **list,
        -:  327:                          DBusList  *before_this_link,
        -:  328:                          void      *data)
function _dbus_list_insert_before called 4 returned 100% blocks executed 89%
        4:  329:{
        -:  330:  DBusList *link;
        -:  331:  
        4:  332:  if (before_this_link == NULL)
branch  0 taken 50% (fallthrough)
branch  1 taken 50%
        2:  333:    return _dbus_list_append (list, data);
call    0 returned 100%
        -:  334:  else
        -:  335:    {
        2:  336:      link = alloc_link (data);
call    0 returned 100%
        2:  337:      if (link == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  338:        return FALSE;
        -:  339:  
        2:  340:      link_before (list, before_this_link, link);
call    0 returned 100%
        -:  341:    }
        -:  342:  
        2:  343:  return TRUE;
        -:  344:}
        -:  345:#endif /* DBUS_BUILD_TESTS */
        -:  346:
        -:  347:/**
        -:  348: * Inserts data into the list after the given existing link.
        -:  349: * 
        -:  350: * @param list the list to modify
        -:  351: * @param after_this_link existing link to insert after, or #NULL to prepend
        -:  352: * @param data the value to insert
        -:  353: * @returns #TRUE on success, #FALSE if memory allocation fails
        -:  354: */
        -:  355:dbus_bool_t
        -:  356:_dbus_list_insert_after (DBusList **list,
        -:  357:                         DBusList  *after_this_link,
        -:  358:                         void      *data)
function _dbus_list_insert_after called 4 returned 100% blocks executed 89%
        4:  359:{
        -:  360:  DBusList *link;  
        -:  361:
        4:  362:  if (after_this_link == NULL)
branch  0 taken 50% (fallthrough)
branch  1 taken 50%
        2:  363:    return _dbus_list_prepend (list, data);
call    0 returned 100%
        -:  364:  else
        -:  365:    {
        2:  366:      link = alloc_link (data);
call    0 returned 100%
        2:  367:      if (link == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  368:        return FALSE;
        -:  369:  
        2:  370:      link_after (list, after_this_link, link);
call    0 returned 100%
        -:  371:    }
        -:  372:  
        2:  373:  return TRUE;
        -:  374:}
        -:  375:
        -:  376:/**
        -:  377: * Inserts a link into the list before the given existing link.
        -:  378: * 
        -:  379: * @param list the list to modify
        -:  380: * @param before_this_link existing link to insert before, or #NULL to append
        -:  381: * @param link the link to insert
        -:  382: */
        -:  383:void
        -:  384:_dbus_list_insert_before_link (DBusList **list,
        -:  385:                               DBusList  *before_this_link,
        -:  386:                               DBusList  *link)
function _dbus_list_insert_before_link called 0 returned 0% blocks executed 0%
    #####:  387:{
    #####:  388:  if (before_this_link == NULL)
branch  0 never executed
branch  1 never executed
    #####:  389:    _dbus_list_append_link (list, link);
call    0 never executed
        -:  390:  else
    #####:  391:    link_before (list, before_this_link, link);
call    0 never executed
    #####:  392:}
        -:  393:
        -:  394:/**
        -:  395: * Inserts a link into the list after the given existing link.
        -:  396: * 
        -:  397: * @param list the list to modify
        -:  398: * @param after_this_link existing link to insert after, or #NULL to prepend
        -:  399: * @param link the link to insert
        -:  400: */
        -:  401:void
        -:  402:_dbus_list_insert_after_link (DBusList **list,
        -:  403:                              DBusList  *after_this_link,
        -:  404:                              DBusList  *link)
function _dbus_list_insert_after_link called 0 returned 0% blocks executed 0%
    #####:  405:{
    #####:  406:  if (after_this_link == NULL)
branch  0 never executed
branch  1 never executed
    #####:  407:    _dbus_list_prepend_link (list, link);
call    0 never executed
        -:  408:  else  
    #####:  409:    link_after (list, after_this_link, link);
call    0 never executed
    #####:  410:}
        -:  411:
        -:  412:/**
        -:  413: * Removes a value from the list. Only removes the
        -:  414: * first value equal to the given data pointer,
        -:  415: * even if multiple values exist which match.
        -:  416: * This is a linear-time operation.
        -:  417: *
        -:  418: * @param list address of the list head.
        -:  419: * @param data the value to remove.
        -:  420: * @returns #TRUE if a value was found to remove.
        -:  421: */
        -:  422:dbus_bool_t
        -:  423:_dbus_list_remove (DBusList **list,
        -:  424:                   void      *data)
function _dbus_list_remove called 34646 returned 100% blocks executed 82%
    34646:  425:{
        -:  426:  DBusList *link;
        -:  427:
    34646:  428:  link = *list;
    91717:  429:  while (link != NULL)
branch  0 taken 100%
branch  1 taken 0% (fallthrough)
        -:  430:    {
    57071:  431:      if (link->data == data)
branch  0 taken 61% (fallthrough)
branch  1 taken 39%
        -:  432:        {
    34646:  433:          _dbus_list_remove_link (list, link);
call    0 returned 100%
    34646:  434:          return TRUE;
        -:  435:        }
        -:  436:      
    22425:  437:      link = _dbus_list_get_next_link (list, link);
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
        -:  438:    }
        -:  439:
    #####:  440:  return FALSE;
        -:  441:}
        -:  442:
        -:  443:/**
        -:  444: * Removes a value from the list. Only removes the
        -:  445: * last value equal to the given data pointer,
        -:  446: * even if multiple values exist which match.
        -:  447: * This is a linear-time operation.
        -:  448: *
        -:  449: * @param list address of the list head.
        -:  450: * @param data the value to remove.
        -:  451: * @returns #TRUE if a value was found to remove.
        -:  452: */
        -:  453:dbus_bool_t
        -:  454:_dbus_list_remove_last (DBusList **list,
        -:  455:                        void      *data)
function _dbus_list_remove_last called 133225 returned 100% blocks executed 100%
   133225:  456:{
        -:  457:  DBusList *link;
        -:  458:
   133225:  459:  link = _dbus_list_find_last (list, data);
call    0 returned 100%
   133225:  460:  if (link)
branch  0 taken 13% (fallthrough)
branch  1 taken 87%
        -:  461:    {
    17374:  462:      _dbus_list_remove_link (list, link);
call    0 returned 100%
    17374:  463:      return TRUE;
        -:  464:    }
        -:  465:  else
   115851:  466:    return FALSE;
        -:  467:}
        -:  468:
        -:  469:/**
        -:  470: * Finds a value in the list. Returns the last link
        -:  471: * with value equal to the given data pointer.
        -:  472: * This is a linear-time operation.
        -:  473: * Returns #NULL if no value found that matches.
        -:  474: *
        -:  475: * @param list address of the list head.
        -:  476: * @param data the value to find.
        -:  477: * @returns the link if found
        -:  478: */
        -:  479:DBusList*
        -:  480:_dbus_list_find_last (DBusList **list,
        -:  481:                      void      *data)
function _dbus_list_find_last called 410249 returned 100% blocks executed 100%
   410249:  482:{
        -:  483:  DBusList *link;
        -:  484:
   410249:  485:  link = _dbus_list_get_last_link (list);
call    0 returned 100%
        -:  486:
   821080:  487:  while (link != NULL)
branch  0 taken 72%
branch  1 taken 28% (fallthrough)
        -:  488:    {
   294972:  489:      if (link->data == data)
branch  0 taken 99% (fallthrough)
branch  1 taken 1%
   294390:  490:        return link;
        -:  491:      
      582:  492:      link = _dbus_list_get_prev_link (list, link);
branch  0 taken 16% (fallthrough)
branch  1 taken 84%
        -:  493:    }
        -:  494:
   115859:  495:  return NULL;
        -:  496:}
        -:  497:
        -:  498:/**
        -:  499: * Removes the given link from the list, but doesn't
        -:  500: * free it. _dbus_list_remove_link() both removes the
        -:  501: * link and also frees it.
        -:  502: *
        -:  503: * @param list the list
        -:  504: * @param link the link in the list
        -:  505: */
        -:  506:void
        -:  507:_dbus_list_unlink (DBusList **list,
        -:  508:                   DBusList  *link)
function _dbus_list_unlink called 1900801 returned 100% blocks executed 100%
  1900801:  509:{
  1900801:  510:  if (link->next == link)
branch  0 taken 85% (fallthrough)
branch  1 taken 15%
        -:  511:    {
        -:  512:      /* one-element list */
  1611827:  513:      *list = NULL;
        -:  514:    }
        -:  515:  else
        -:  516:    {      
   288974:  517:      link->prev->next = link->next;
   288974:  518:      link->next->prev = link->prev;
        -:  519:      
   288974:  520:      if (*list == link)
branch  0 taken 45% (fallthrough)
branch  1 taken 55%
   128903:  521:        *list = link->next;
        -:  522:    }
        -:  523:
  1900801:  524:  link->next = NULL;
  1900801:  525:  link->prev = NULL;
  1900801:  526:}
        -:  527:
        -:  528:/**
        -:  529: * Removes a link from the list. This is a constant-time operation.
        -:  530: *
        -:  531: * @param list address of the list head.
        -:  532: * @param link the list link to remove.
        -:  533: */
        -:  534:void
        -:  535:_dbus_list_remove_link (DBusList **list,
        -:  536:                        DBusList  *link)
function _dbus_list_remove_link called 1475235 returned 100% blocks executed 100%
  1475235:  537:{
  1475235:  538:  _dbus_list_unlink (list, link);
call    0 returned 100%
  1475235:  539:  free_link (link);
call    0 returned 100%
  1475235:  540:}
        -:  541:
        -:  542:/**
        -:  543: * Frees all links in the list and sets the list head to #NULL. Does
        -:  544: * not free the data in each link, for obvious reasons. This is a
        -:  545: * linear-time operation.
        -:  546: *
        -:  547: * @param list address of the list head.
        -:  548: */
        -:  549:void
        -:  550:_dbus_list_clear (DBusList **list)
function _dbus_list_clear called 1863938 returned 100% blocks executed 100%
  1863938:  551:{
        -:  552:  DBusList *link;
        -:  553:
  1863938:  554:  link = *list;
  5132764:  555:  while (link != NULL)
branch  0 taken 43%
branch  1 taken 57% (fallthrough)
        -:  556:    {
  1404888:  557:      DBusList *next = _dbus_list_get_next_link (list, link);
branch  0 taken 6% (fallthrough)
branch  1 taken 94%
        -:  558:      
  1404888:  559:      free_link (link);
call    0 returned 100%
        -:  560:      
  1404888:  561:      link = next;
        -:  562:    }
        -:  563:
  1863938:  564:  *list = NULL;
  1863938:  565:}
        -:  566:
        -:  567:/**
        -:  568: * Gets the first link in the list.
        -:  569: * This is a constant-time operation.
        -:  570: *
        -:  571: * @param list address of the list head.
        -:  572: * @returns the first link, or #NULL for an empty list.
        -:  573: */
        -:  574:DBusList*
        -:  575:_dbus_list_get_first_link (DBusList **list)
function _dbus_list_get_first_link called 4095751 returned 100% blocks executed 100%
  4095751:  576:{
  4095751:  577:  return *list;
        -:  578:}
        -:  579:
        -:  580:/**
        -:  581: * Gets the last link in the list.
        -:  582: * This is a constant-time operation.
        -:  583: *
        -:  584: * @param list address of the list head.
        -:  585: * @returns the last link, or #NULL for an empty list.
        -:  586: */
        -:  587:DBusList*
        -:  588:_dbus_list_get_last_link (DBusList **list)
function _dbus_list_get_last_link called 1767329 returned 100% blocks executed 100%
  1767329:  589:{
  1767329:  590:  if (*list == NULL)
branch  0 taken 7% (fallthrough)
branch  1 taken 93%
   117033:  591:    return NULL;
        -:  592:  else
  1650296:  593:    return (*list)->prev;
        -:  594:}
        -:  595:
        -:  596:/**
        -:  597: * Gets the last data in the list.
        -:  598: * This is a constant-time operation.
        -:  599: *
        -:  600: * @param list address of the list head.
        -:  601: * @returns the last data in the list, or #NULL for an empty list.
        -:  602: */
        -:  603:void*
        -:  604:_dbus_list_get_last (DBusList **list)
function _dbus_list_get_last called 90376 returned 100% blocks executed 100%
    90376:  605:{
    90376:  606:  if (*list == NULL)
branch  0 taken 9% (fallthrough)
branch  1 taken 91%
     7847:  607:    return NULL;
        -:  608:  else
    82529:  609:    return (*list)->prev->data;
        -:  610:}
        -:  611:
        -:  612:/**
        -:  613: * Gets the first data in the list.
        -:  614: * This is a constant-time operation.
        -:  615: *
        -:  616: * @param list address of the list head.
        -:  617: * @returns the first data in the list, or #NULL for an empty list.
        -:  618: */
        -:  619:void*
        -:  620:_dbus_list_get_first (DBusList **list)
function _dbus_list_get_first called 79442 returned 100% blocks executed 100%
    79442:  621:{
    79442:  622:  if (*list == NULL)
branch  0 taken 10% (fallthrough)
branch  1 taken 90%
     7811:  623:    return NULL;
        -:  624:  else
    71631:  625:    return (*list)->data;
        -:  626:}
        -:  627:
        -:  628:/**
        -:  629: * Removes the first link in the list and returns it.  This is a
        -:  630: * constant-time operation.
        -:  631: *
        -:  632: * @param list address of the list head.
        -:  633: * @returns the first link in the list, or #NULL for an empty list.
        -:  634: */
        -:  635:DBusList*
        -:  636:_dbus_list_pop_first_link (DBusList **list)
function _dbus_list_pop_first_link called 268269 returned 100% blocks executed 100%
   268269:  637:{
        -:  638:  DBusList *link;
        -:  639:  
   268269:  640:  link = _dbus_list_get_first_link (list);
call    0 returned 100%
   268269:  641:  if (link == NULL)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
       25:  642:    return NULL;
        -:  643:
   268244:  644:  _dbus_list_unlink (list, link);
call    0 returned 100%
        -:  645:
   268244:  646:  return link;
        -:  647:}
        -:  648:
        -:  649:/**
        -:  650: * Removes the first value in the list and returns it.  This is a
        -:  651: * constant-time operation.
        -:  652: *
        -:  653: * @param list address of the list head.
        -:  654: * @returns the first data in the list, or #NULL for an empty list.
        -:  655: */
        -:  656:void*
        -:  657:_dbus_list_pop_first (DBusList **list)
function _dbus_list_pop_first called 108954 returned 100% blocks executed 100%
   108954:  658:{
        -:  659:  DBusList *link;
        -:  660:  void *data;
        -:  661:  
   108954:  662:  link = _dbus_list_get_first_link (list);
call    0 returned 100%
   108954:  663:  if (link == NULL)
branch  0 taken 26% (fallthrough)
branch  1 taken 74%
    28644:  664:    return NULL;
        -:  665:  
    80310:  666:  data = link->data;
    80310:  667:  _dbus_list_remove_link (list, link);
call    0 returned 100%
        -:  668:
    80310:  669:  return data;
        -:  670:}
        -:  671:
        -:  672:/**
        -:  673: * Removes the last value in the list and returns it.  This is a
        -:  674: * constant-time operation.
        -:  675: *
        -:  676: * @param list address of the list head.
        -:  677: * @returns the last data in the list, or #NULL for an empty list.
        -:  678: */
        -:  679:void*
        -:  680:_dbus_list_pop_last (DBusList **list)
function _dbus_list_pop_last called 1223420 returned 100% blocks executed 83%
  1223420:  681:{
        -:  682:  DBusList *link;
        -:  683:  void *data;
        -:  684:  
  1223420:  685:  link = _dbus_list_get_last_link (list);
call    0 returned 100%
  1223420:  686:  if (link == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  687:    return NULL;
        -:  688:  
  1223420:  689:  data = link->data;
  1223420:  690:  _dbus_list_remove_link (list, link);
call    0 returned 100%
        -:  691:
  1223420:  692:  return data;
        -:  693:}
        -:  694:
        -:  695:#ifdef DBUS_BUILD_TESTS
        -:  696:/**
        -:  697: * Removes the last link in the list and returns it.  This is a
        -:  698: * constant-time operation.
        -:  699: *
        -:  700: * @param list address of the list head.
        -:  701: * @returns the last link in the list, or #NULL for an empty list.
        -:  702: */
        -:  703:DBusList*
        -:  704:_dbus_list_pop_last_link (DBusList **list)
function _dbus_list_pop_last_link called 10 returned 100% blocks executed 83%
       10:  705:{
        -:  706:  DBusList *link;
        -:  707:  
       10:  708:  link = _dbus_list_get_last_link (list);
call    0 returned 100%
       10:  709:  if (link == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  710:    return NULL;
        -:  711:
       10:  712:  _dbus_list_unlink (list, link);
call    0 returned 100%
        -:  713:
       10:  714:  return link;
        -:  715:}
        -:  716:#endif /* DBUS_BUILD_TESTS */
        -:  717:
        -:  718:/**
        -:  719: * Copies a list. This is a linear-time operation.  If there isn't
        -:  720: * enough memory to copy the entire list, the destination list will be
        -:  721: * set to #NULL.
        -:  722: *
        -:  723: * @param list address of the head of the list to copy.
        -:  724: * @param dest address where the copied list should be placed.
        -:  725: * @returns #TRUE on success, #FALSE if not enough memory.
        -:  726: */
        -:  727:dbus_bool_t
        -:  728:_dbus_list_copy (DBusList **list,
        -:  729:                 DBusList **dest)
function _dbus_list_copy called 31606 returned 100% blocks executed 100%
    31606:  730:{
        -:  731:  DBusList *link;
        -:  732:
    31606:  733:  _dbus_assert (list != dest);
call    0 returned 100%
        -:  734:
    31606:  735:  *dest = NULL;
        -:  736:  
    31606:  737:  link = *list;
    94767:  738:  while (link != NULL)
branch  0 taken 50%
branch  1 taken 50% (fallthrough)
        -:  739:    {
    31622:  740:      if (!_dbus_list_append (dest, link->data))
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -:  741:        {
        -:  742:          /* free what we have so far */
       67:  743:          _dbus_list_clear (dest);
call    0 returned 100%
       67:  744:          return FALSE;
        -:  745:        }
        -:  746:      
    31555:  747:      link = _dbus_list_get_next_link (list, link);
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        -:  748:    }
        -:  749:
    31539:  750:  return TRUE;
        -:  751:}
        -:  752:
        -:  753:/**
        -:  754: * Gets the length of a list. This is a linear-time
        -:  755: * operation.
        -:  756: *
        -:  757: * @param list address of the head of the list
        -:  758: * @returns number of elements in the list.
        -:  759: */
        -:  760:int
        -:  761:_dbus_list_get_length (DBusList **list)
function _dbus_list_get_length called 23617 returned 100% blocks executed 100%
    23617:  762:{
        -:  763:  DBusList *link;
        -:  764:  int length;
        -:  765:
    23617:  766:  length = 0;
        -:  767:  
    23617:  768:  link = *list;
    98314:  769:  while (link != NULL)
branch  0 taken 68%
branch  1 taken 32% (fallthrough)
        -:  770:    {
    51080:  771:      ++length;
        -:  772:      
    51080:  773:      link = _dbus_list_get_next_link (list, link);
branch  0 taken 54% (fallthrough)
branch  1 taken 46%
        -:  774:    }
        -:  775:
    23617:  776:  return length;
        -:  777:}
        -:  778:
        -:  779:/**
        -:  780: * Calls the given function for each element in the list.  The
        -:  781: * function is passed the list element as its first argument, and the
        -:  782: * given data as its second argument.
        -:  783: *
        -:  784: * @param list address of the head of the list.
        -:  785: * @param function function to call for each element.
        -:  786: * @param data extra data for the function.
        -:  787: * 
        -:  788: */
        -:  789:void
        -:  790:_dbus_list_foreach (DBusList          **list,
        -:  791:                    DBusForeachFunction function,
        -:  792:                    void               *data)
function _dbus_list_foreach called 740862 returned 100% blocks executed 100%
   740862:  793:{
        -:  794:  DBusList *link;
        -:  795:
   740862:  796:  link = *list;
  1703256:  797:  while (link != NULL)
branch  0 taken 23%
branch  1 taken 77% (fallthrough)
        -:  798:    {
   221532:  799:      DBusList *next = _dbus_list_get_next_link (list, link);
branch  0 taken 9% (fallthrough)
branch  1 taken 91%
        -:  800:      
   221532:  801:      (* function) (link->data, data);
call    0 returned 100%
        -:  802:      
   221532:  803:      link = next;
        -:  804:    }
   740862:  805:}
        -:  806:
        -:  807:/**
        -:  808: * Check whether length is exactly one.
        -:  809: *
        -:  810: * @param list the list
        -:  811: * @returns #TRUE if length is exactly one
        -:  812: */
        -:  813:dbus_bool_t
        -:  814:_dbus_list_length_is_one (DBusList **list)
function _dbus_list_length_is_one called 13736 returned 100% blocks executed 100%
    13736:  815:{
    13736:  816:  return (*list != NULL &&
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
branch  2 taken 99% (fallthrough)
branch  3 taken 1%
        -:  817:          (*list)->next == *list);
        -:  818:}
        -:  819:
        -:  820:/** @} */
        -:  821:
        -:  822:#ifdef DBUS_BUILD_TESTS
        -:  823:#include "dbus-test.h"
        -:  824:#include <stdio.h>
        -:  825:
        -:  826:static void
        -:  827:verify_list (DBusList **list)
function verify_list called 179 returned 100% blocks executed 89%
      179:  828:{
        -:  829:  DBusList *link;
        -:  830:  int length;
        -:  831:  
      179:  832:  link = *list;
        -:  833:
      179:  834:  if (link == NULL)
branch  0 taken 7% (fallthrough)
branch  1 taken 93%
       12:  835:    return;
        -:  836:
      167:  837:  if (link->next == link)
branch  0 taken 7% (fallthrough)
branch  1 taken 93%
        -:  838:    {
       12:  839:      _dbus_assert (link->prev == link);
call    0 returned 100%
       12:  840:      _dbus_assert (*list == link);
call    0 returned 100%
       12:  841:      return;
        -:  842:    }
        -:  843:
      155:  844:  length = 0;
        -:  845:  do
        -:  846:    {
     1060:  847:      length += 1;
     1060:  848:      _dbus_assert (link->prev->next == link);
call    0 returned 100%
     1060:  849:      _dbus_assert (link->next->prev == link);
call    0 returned 100%
     1060:  850:      link = link->next;
        -:  851:    }
     1060:  852:  while (link != *list);
branch  0 taken 85%
branch  1 taken 15% (fallthrough)
        -:  853:
      155:  854:  _dbus_assert (length == _dbus_list_get_length (list));
call    0 returned 100%
call    1 returned 100%
        -:  855:
      155:  856:  if (length == 1)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  857:    _dbus_assert (_dbus_list_length_is_one (list));
call    0 never executed
call    1 never executed
        -:  858:  else
      155:  859:    _dbus_assert (!_dbus_list_length_is_one (list));
call    0 returned 100%
call    1 returned 100%
        -:  860:}
        -:  861:
        -:  862:static dbus_bool_t
        -:  863:is_ascending_sequence (DBusList **list)
function is_ascending_sequence called 26 returned 100% blocks executed 91%
       26:  864:{
        -:  865:  DBusList *link;
        -:  866:  int prev;
        -:  867:
       26:  868:  prev = _DBUS_INT_MIN;
        -:  869:  
       26:  870:  link = _dbus_list_get_first_link (list);
call    0 returned 100%
      173:  871:  while (link != NULL)
branch  0 taken 82%
branch  1 taken 18% (fallthrough)
        -:  872:    {
      121:  873:      int v = _DBUS_POINTER_TO_INT (link->data);
        -:  874:      
      121:  875:      if (v <= prev)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  876:        return FALSE;
        -:  877:
      121:  878:      prev = v;
        -:  879:      
      121:  880:      link = _dbus_list_get_next_link (list, link);
branch  0 taken 80% (fallthrough)
branch  1 taken 20%
        -:  881:    }
        -:  882:
       26:  883:  return TRUE;
        -:  884:}
        -:  885:
        -:  886:static dbus_bool_t
        -:  887:is_descending_sequence (DBusList **list)
function is_descending_sequence called 25 returned 100% blocks executed 91%
       25:  888:{
        -:  889:  DBusList *link;
        -:  890:  int prev;
        -:  891:
       25:  892:  prev = _DBUS_INT_MAX;
        -:  893:  
       25:  894:  link = _dbus_list_get_first_link (list);
call    0 returned 100%
      169:  895:  while (link != NULL)
branch  0 taken 83%
branch  1 taken 17% (fallthrough)
        -:  896:    {
      119:  897:      int v = _DBUS_POINTER_TO_INT (link->data);
        -:  898:
      119:  899:      if (v >= prev)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  900:        return FALSE;
        -:  901:
      119:  902:      prev = v;
        -:  903:      
      119:  904:      link = _dbus_list_get_next_link (list, link);
branch  0 taken 81% (fallthrough)
branch  1 taken 19%
        -:  905:    }
        -:  906:
       25:  907:  return TRUE;
        -:  908:}
        -:  909:
        -:  910:static dbus_bool_t
        -:  911:all_even_values (DBusList **list)
function all_even_values called 3 returned 100% blocks executed 91%
        3:  912:{
        -:  913:  DBusList *link;
        -:  914:  
        3:  915:  link = _dbus_list_get_first_link (list);
call    0 returned 100%
       21:  916:  while (link != NULL)
branch  0 taken 83%
branch  1 taken 17% (fallthrough)
        -:  917:    {
       15:  918:      int v = _DBUS_POINTER_TO_INT (link->data);
        -:  919:
       15:  920:      if ((v % 2) != 0)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  921:        return FALSE;
        -:  922:      
       15:  923:      link = _dbus_list_get_next_link (list, link);
branch  0 taken 80% (fallthrough)
branch  1 taken 20%
        -:  924:    }
        -:  925:
        3:  926:  return TRUE;
        -:  927:}
        -:  928:
        -:  929:static dbus_bool_t
        -:  930:all_odd_values (DBusList **list)
function all_odd_values called 3 returned 100% blocks executed 91%
        3:  931:{
        -:  932:  DBusList *link;
        -:  933:  
        3:  934:  link = _dbus_list_get_first_link (list);
call    0 returned 100%
       21:  935:  while (link != NULL)
branch  0 taken 83%
branch  1 taken 17% (fallthrough)
        -:  936:    {
       15:  937:      int v = _DBUS_POINTER_TO_INT (link->data);
        -:  938:
       15:  939:      if ((v % 2) == 0)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  940:        return FALSE;
        -:  941:      
       15:  942:      link = _dbus_list_get_next_link (list, link);
branch  0 taken 80% (fallthrough)
branch  1 taken 20%
        -:  943:    }
        -:  944:
        3:  945:  return TRUE;
        -:  946:}
        -:  947:
        -:  948:static dbus_bool_t
        -:  949:lists_equal (DBusList **list1,
        -:  950:             DBusList **list2)
function lists_equal called 4 returned 100% blocks executed 89%
        4:  951:{
        -:  952:  DBusList *link1;
        -:  953:  DBusList *link2;
        -:  954:  
        4:  955:  link1 = _dbus_list_get_first_link (list1);
call    0 returned 100%
        4:  956:  link2 = _dbus_list_get_first_link (list2);
call    0 returned 100%
       28:  957:  while (link1 && link2)
branch  0 taken 83% (fallthrough)
branch  1 taken 17%
branch  2 taken 100%
branch  3 taken 0% (fallthrough)
        -:  958:    {
       20:  959:      if (link1->data != link2->data)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  960:        return FALSE;
        -:  961:      
       20:  962:      link1 = _dbus_list_get_next_link (list1, link1);
branch  0 taken 90% (fallthrough)
branch  1 taken 10%
       20:  963:      link2 = _dbus_list_get_next_link (list2, link2);
branch  0 taken 90% (fallthrough)
branch  1 taken 10%
        -:  964:    }
        -:  965:
        4:  966:  if (link1 || link2)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
branch  2 taken 0% (fallthrough)
branch  3 taken 100%
    #####:  967:    return FALSE;
        -:  968:
        4:  969:  return TRUE;
        -:  970:}
        -:  971:
        -:  972:/**
        -:  973: * @ingroup DBusListInternals
        -:  974: * Unit test for DBusList
        -:  975: * @returns #TRUE on success.
        -:  976: */
        -:  977:dbus_bool_t
        -:  978:_dbus_list_test (void)
function _dbus_list_test called 1 returned 100% blocks executed 98%
        1:  979:{
        -:  980:  DBusList *list1;
        -:  981:  DBusList *list2;
        -:  982:  DBusList *link1;
        -:  983:  DBusList *link2;
        -:  984:  DBusList *copy1;
        -:  985:  DBusList *copy2;
        -:  986:  int i;
        -:  987:  
        1:  988:  list1 = NULL;
        1:  989:  list2 = NULL;
        -:  990:
        -:  991:  /* Test append and prepend */
        -:  992:  
        1:  993:  i = 0;
       12:  994:  while (i < 10)
branch  0 taken 91%
branch  1 taken 9% (fallthrough)
        -:  995:    {
       10:  996:      if (!_dbus_list_append (&list1, _DBUS_INT_TO_POINTER (i)))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####:  997:        _dbus_assert_not_reached ("could not allocate for append");
call    0 never executed
        -:  998:      
       10:  999:      if (!_dbus_list_prepend (&list2, _DBUS_INT_TO_POINTER (i)))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1000:        _dbus_assert_not_reached ("count not allocate for prepend");
call    0 never executed
       10: 1001:      ++i;
        -: 1002:
       10: 1003:      verify_list (&list1);
call    0 returned 100%
       10: 1004:      verify_list (&list2);
call    0 returned 100%
        -: 1005:      
       10: 1006:      _dbus_assert (_dbus_list_get_length (&list1) == i);
call    0 returned 100%
call    1 returned 100%
       10: 1007:      _dbus_assert (_dbus_list_get_length (&list2) == i);
call    0 returned 100%
call    1 returned 100%
        -: 1008:    }
        -: 1009:
        1: 1010:  _dbus_assert (is_ascending_sequence (&list1));
call    0 returned 100%
call    1 returned 100%
        1: 1011:  _dbus_assert (is_descending_sequence (&list2));
call    0 returned 100%
call    1 returned 100%
        -: 1012:
        -: 1013:  /* Test list clear */
        1: 1014:  _dbus_list_clear (&list1);
call    0 returned 100%
        1: 1015:  _dbus_list_clear (&list2);
call    0 returned 100%
        -: 1016:
        1: 1017:  verify_list (&list1);
call    0 returned 100%
        1: 1018:  verify_list (&list2);
call    0 returned 100%
        -: 1019:
        -: 1020:  /* Test get_first, get_last, pop_first, pop_last */
        -: 1021:  
        1: 1022:  i = 0;
       12: 1023:  while (i < 10)
branch  0 taken 91%
branch  1 taken 9% (fallthrough)
        -: 1024:    {
       10: 1025:      _dbus_list_append (&list1, _DBUS_INT_TO_POINTER (i));
call    0 returned 100%
       10: 1026:      _dbus_list_prepend (&list2, _DBUS_INT_TO_POINTER (i));
call    0 returned 100%
       10: 1027:      ++i;
        -: 1028:    }
        -: 1029:
        1: 1030:  --i;
       12: 1031:  while (i >= 0)
branch  0 taken 91%
branch  1 taken 9% (fallthrough)
        -: 1032:    {
        -: 1033:      void *got_data1;
        -: 1034:      void *got_data2;
        -: 1035:      
        -: 1036:      void *data1;
        -: 1037:      void *data2;
        -: 1038:
       10: 1039:      got_data1 = _dbus_list_get_last (&list1);
call    0 returned 100%
       10: 1040:      got_data2 = _dbus_list_get_first (&list2);
call    0 returned 100%
        -: 1041:      
       10: 1042:      data1 = _dbus_list_pop_last (&list1);
call    0 returned 100%
       10: 1043:      data2 = _dbus_list_pop_first (&list2);
call    0 returned 100%
        -: 1044:
       10: 1045:      _dbus_assert (got_data1 == data1);
call    0 returned 100%
       10: 1046:      _dbus_assert (got_data2 == data2);
call    0 returned 100%
        -: 1047:      
       10: 1048:      _dbus_assert (_DBUS_POINTER_TO_INT (data1) == i);
call    0 returned 100%
       10: 1049:      _dbus_assert (_DBUS_POINTER_TO_INT (data2) == i);
call    0 returned 100%
        -: 1050:
       10: 1051:      verify_list (&list1);
call    0 returned 100%
       10: 1052:      verify_list (&list2);
call    0 returned 100%
        -: 1053:
       10: 1054:      _dbus_assert (is_ascending_sequence (&list1));
call    0 returned 100%
call    1 returned 100%
       10: 1055:      _dbus_assert (is_descending_sequence (&list2));
call    0 returned 100%
call    1 returned 100%
        -: 1056:      
       10: 1057:      --i;
        -: 1058:    }
        -: 1059:
        1: 1060:  _dbus_assert (list1 == NULL);
call    0 returned 100%
        1: 1061:  _dbus_assert (list2 == NULL);
call    0 returned 100%
        -: 1062:
        -: 1063:  /* Test get_first_link, get_last_link, pop_first_link, pop_last_link */
        -: 1064:  
        1: 1065:  i = 0;
       12: 1066:  while (i < 10)
branch  0 taken 91%
branch  1 taken 9% (fallthrough)
        -: 1067:    {
       10: 1068:      _dbus_list_append (&list1, _DBUS_INT_TO_POINTER (i));
call    0 returned 100%
       10: 1069:      _dbus_list_prepend (&list2, _DBUS_INT_TO_POINTER (i));
call    0 returned 100%
       10: 1070:      ++i;
        -: 1071:    }
        -: 1072:
        1: 1073:  --i;
       12: 1074:  while (i >= 0)
branch  0 taken 91%
branch  1 taken 9% (fallthrough)
        -: 1075:    {
        -: 1076:      DBusList *got_link1;
        -: 1077:      DBusList *got_link2;
        -: 1078:
        -: 1079:      DBusList *link1;
        -: 1080:      DBusList *link2;
        -: 1081:      
        -: 1082:      void *data1;
        -: 1083:      void *data2;
        -: 1084:      
       10: 1085:      got_link1 = _dbus_list_get_last_link (&list1);
call    0 returned 100%
       10: 1086:      got_link2 = _dbus_list_get_first_link (&list2);
call    0 returned 100%
        -: 1087:      
       10: 1088:      link1 = _dbus_list_pop_last_link (&list1);
call    0 returned 100%
       10: 1089:      link2 = _dbus_list_pop_first_link (&list2);
call    0 returned 100%
        -: 1090:
       10: 1091:      _dbus_assert (got_link1 == link1);
call    0 returned 100%
       10: 1092:      _dbus_assert (got_link2 == link2);
call    0 returned 100%
        -: 1093:
       10: 1094:      data1 = link1->data;
       10: 1095:      data2 = link2->data;
        -: 1096:
       10: 1097:      _dbus_list_free_link (link1);
call    0 returned 100%
       10: 1098:      _dbus_list_free_link (link2);
call    0 returned 100%
        -: 1099:      
       10: 1100:      _dbus_assert (_DBUS_POINTER_TO_INT (data1) == i);
call    0 returned 100%
       10: 1101:      _dbus_assert (_DBUS_POINTER_TO_INT (data2) == i);
call    0 returned 100%
        -: 1102:
       10: 1103:      verify_list (&list1);
call    0 returned 100%
       10: 1104:      verify_list (&list2);
call    0 returned 100%
        -: 1105:
       10: 1106:      _dbus_assert (is_ascending_sequence (&list1));
call    0 returned 100%
call    1 returned 100%
       10: 1107:      _dbus_assert (is_descending_sequence (&list2));
call    0 returned 100%
call    1 returned 100%
        -: 1108:      
       10: 1109:      --i;
        -: 1110:    }
        -: 1111:
        1: 1112:  _dbus_assert (list1 == NULL);
call    0 returned 100%
        1: 1113:  _dbus_assert (list2 == NULL);
call    0 returned 100%
        -: 1114:  
        -: 1115:  /* Test iteration */
        -: 1116:  
        1: 1117:  i = 0;
       12: 1118:  while (i < 10)
branch  0 taken 91%
branch  1 taken 9% (fallthrough)
        -: 1119:    {
       10: 1120:      _dbus_list_append (&list1, _DBUS_INT_TO_POINTER (i));
call    0 returned 100%
       10: 1121:      _dbus_list_prepend (&list2, _DBUS_INT_TO_POINTER (i));
call    0 returned 100%
       10: 1122:      ++i;
        -: 1123:
       10: 1124:      verify_list (&list1);
call    0 returned 100%
       10: 1125:      verify_list (&list2);
call    0 returned 100%
        -: 1126:      
       10: 1127:      _dbus_assert (_dbus_list_get_length (&list1) == i);
call    0 returned 100%
call    1 returned 100%
       10: 1128:      _dbus_assert (_dbus_list_get_length (&list2) == i);
call    0 returned 100%
call    1 returned 100%
        -: 1129:    }
        -: 1130:
        1: 1131:  _dbus_assert (is_ascending_sequence (&list1));
call    0 returned 100%
call    1 returned 100%
        1: 1132:  _dbus_assert (is_descending_sequence (&list2));
call    0 returned 100%
call    1 returned 100%
        -: 1133:
        1: 1134:  --i;
        1: 1135:  link2 = _dbus_list_get_first_link (&list2);
call    0 returned 100%
       12: 1136:  while (link2 != NULL)
branch  0 taken 91%
branch  1 taken 9% (fallthrough)
        -: 1137:    {
       10: 1138:      verify_list (&link2); /* pretend this link is the head */
call    0 returned 100%
        -: 1139:      
       10: 1140:      _dbus_assert (_DBUS_POINTER_TO_INT (link2->data) == i);
call    0 returned 100%
        -: 1141:      
       10: 1142:      link2 = _dbus_list_get_next_link (&list2, link2);
branch  0 taken 90% (fallthrough)
branch  1 taken 10%
       10: 1143:      --i;
        -: 1144:    }
        -: 1145:
        1: 1146:  i = 0;
        1: 1147:  link1 = _dbus_list_get_first_link (&list1);
call    0 returned 100%
       12: 1148:  while (link1 != NULL)
branch  0 taken 91%
branch  1 taken 9% (fallthrough)
        -: 1149:    {
       10: 1150:      verify_list (&link1); /* pretend this link is the head */
call    0 returned 100%
        -: 1151:      
       10: 1152:      _dbus_assert (_DBUS_POINTER_TO_INT (link1->data) == i);
call    0 returned 100%
        -: 1153:      
       10: 1154:      link1 = _dbus_list_get_next_link (&list1, link1);
branch  0 taken 90% (fallthrough)
branch  1 taken 10%
       10: 1155:      ++i;
        -: 1156:    }
        -: 1157:
        1: 1158:  --i;
        1: 1159:  link1 = _dbus_list_get_last_link (&list1);
call    0 returned 100%
       12: 1160:  while (link1 != NULL)
branch  0 taken 91%
branch  1 taken 9% (fallthrough)
        -: 1161:    {
       10: 1162:      verify_list (&link1); /* pretend this link is the head */
call    0 returned 100%
        -: 1163:
       10: 1164:      _dbus_assert (_DBUS_POINTER_TO_INT (link1->data) == i);
call    0 returned 100%
        -: 1165:      
       10: 1166:      link1 = _dbus_list_get_prev_link (&list1, link1);
branch  0 taken 90% (fallthrough)
branch  1 taken 10%
       10: 1167:      --i;
        -: 1168:    }
        -: 1169:
        1: 1170:  _dbus_list_clear (&list1);
call    0 returned 100%
        1: 1171:  _dbus_list_clear (&list2);
call    0 returned 100%
        -: 1172:
        -: 1173:  /* Test remove */
        -: 1174:  
        1: 1175:  i = 0;
       12: 1176:  while (i < 10)
branch  0 taken 91%
branch  1 taken 9% (fallthrough)
        -: 1177:    {
       10: 1178:      _dbus_list_append (&list1, _DBUS_INT_TO_POINTER (i));
call    0 returned 100%
       10: 1179:      _dbus_list_prepend (&list2, _DBUS_INT_TO_POINTER (i));
call    0 returned 100%
       10: 1180:      ++i;
        -: 1181:    }
        -: 1182:
        1: 1183:  --i;
       12: 1184:  while (i >= 0)
branch  0 taken 91%
branch  1 taken 9% (fallthrough)
        -: 1185:    {
       10: 1186:      if ((i % 2) == 0)
branch  0 taken 50% (fallthrough)
branch  1 taken 50%
        -: 1187:        {
        5: 1188:          if (!_dbus_list_remove (&list1, _DBUS_INT_TO_POINTER (i)))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1189:            _dbus_assert_not_reached ("element should have been in list");
call    0 never executed
        5: 1190:          if (!_dbus_list_remove (&list2, _DBUS_INT_TO_POINTER (i)))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1191:            _dbus_assert_not_reached ("element should have been in list");
call    0 never executed
        -: 1192:
        5: 1193:          verify_list (&list1);
call    0 returned 100%
        5: 1194:          verify_list (&list2);
call    0 returned 100%
        -: 1195:        }
       10: 1196:      --i;
        -: 1197:    }
        -: 1198:
        1: 1199:  _dbus_assert (all_odd_values (&list1));
call    0 returned 100%
call    1 returned 100%
        1: 1200:  _dbus_assert (all_odd_values (&list2));
call    0 returned 100%
call    1 returned 100%
        -: 1201:
        1: 1202:  _dbus_list_clear (&list1);
call    0 returned 100%
        1: 1203:  _dbus_list_clear (&list2);
call    0 returned 100%
        -: 1204:
        -: 1205:  /* test removing the other half of the elements */
        -: 1206:  
        1: 1207:  i = 0;
       12: 1208:  while (i < 10)
branch  0 taken 91%
branch  1 taken 9% (fallthrough)
        -: 1209:    {
       10: 1210:      _dbus_list_append (&list1, _DBUS_INT_TO_POINTER (i));
call    0 returned 100%
       10: 1211:      _dbus_list_prepend (&list2, _DBUS_INT_TO_POINTER (i));
call    0 returned 100%
       10: 1212:      ++i;
        -: 1213:    }
        -: 1214:
        1: 1215:  --i;
       12: 1216:  while (i >= 0)
branch  0 taken 91%
branch  1 taken 9% (fallthrough)
        -: 1217:    {
       10: 1218:      if ((i % 2) != 0)
branch  0 taken 50% (fallthrough)
branch  1 taken 50%
        -: 1219:        {
        5: 1220:          if (!_dbus_list_remove (&list1, _DBUS_INT_TO_POINTER (i)))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1221:            _dbus_assert_not_reached ("element should have been in list");
call    0 never executed
        5: 1222:          if (!_dbus_list_remove (&list2, _DBUS_INT_TO_POINTER (i)))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1223:            _dbus_assert_not_reached ("element should have been in list");
call    0 never executed
        -: 1224:
        5: 1225:          verify_list (&list1);
call    0 returned 100%
        5: 1226:          verify_list (&list2);
call    0 returned 100%
        -: 1227:        }
       10: 1228:      --i;
        -: 1229:    }
        -: 1230:
        1: 1231:  _dbus_assert (all_even_values (&list1));
call    0 returned 100%
call    1 returned 100%
        1: 1232:  _dbus_assert (all_even_values (&list2));
call    0 returned 100%
call    1 returned 100%
        -: 1233:
        -: 1234:  /* clear list using remove_link */
        7: 1235:  while (list1 != NULL)
branch  0 taken 83%
branch  1 taken 17% (fallthrough)
        -: 1236:    {
        5: 1237:      _dbus_list_remove_link (&list1, list1);
call    0 returned 100%
        5: 1238:      verify_list (&list1);
call    0 returned 100%
        -: 1239:    }
        7: 1240:  while (list2 != NULL)
branch  0 taken 83%
branch  1 taken 17% (fallthrough)
        -: 1241:    {
        5: 1242:      _dbus_list_remove_link (&list2, list2);
call    0 returned 100%
        5: 1243:      verify_list (&list2);
call    0 returned 100%
        -: 1244:    }
        -: 1245:
        -: 1246:  /* Test remove link more generally */
        1: 1247:  i = 0;
       12: 1248:  while (i < 10)
branch  0 taken 91%
branch  1 taken 9% (fallthrough)
        -: 1249:    {
       10: 1250:      _dbus_list_append (&list1, _DBUS_INT_TO_POINTER (i));
call    0 returned 100%
       10: 1251:      _dbus_list_prepend (&list2, _DBUS_INT_TO_POINTER (i));
call    0 returned 100%
       10: 1252:      ++i;
        -: 1253:    }
        -: 1254:
        1: 1255:  --i;
        1: 1256:  link2 = _dbus_list_get_first_link (&list2);
call    0 returned 100%
       12: 1257:  while (link2 != NULL)
branch  0 taken 91%
branch  1 taken 9% (fallthrough)
        -: 1258:    {
       10: 1259:      DBusList *next = _dbus_list_get_next_link (&list2, link2);
branch  0 taken 90% (fallthrough)
branch  1 taken 10%
        -: 1260:      
       10: 1261:      _dbus_assert (_DBUS_POINTER_TO_INT (link2->data) == i);
call    0 returned 100%
        -: 1262:
       10: 1263:      if ((i % 2) == 0)
branch  0 taken 50% (fallthrough)
branch  1 taken 50%
        5: 1264:        _dbus_list_remove_link (&list2, link2);
call    0 returned 100%
        -: 1265:
       10: 1266:      verify_list (&list2);
call    0 returned 100%
        -: 1267:      
       10: 1268:      link2 = next;
       10: 1269:      --i;
        -: 1270:    }
        -: 1271:
        1: 1272:  _dbus_assert (all_odd_values (&list2));  
call    0 returned 100%
call    1 returned 100%
        1: 1273:  _dbus_list_clear (&list2);
call    0 returned 100%
        -: 1274:  
        1: 1275:  i = 0;
        1: 1276:  link1 = _dbus_list_get_first_link (&list1);
call    0 returned 100%
       12: 1277:  while (link1 != NULL)
branch  0 taken 91%
branch  1 taken 9% (fallthrough)
        -: 1278:    {
       10: 1279:      DBusList *next = _dbus_list_get_next_link (&list1, link1);
branch  0 taken 90% (fallthrough)
branch  1 taken 10%
        -: 1280:
       10: 1281:      _dbus_assert (_DBUS_POINTER_TO_INT (link1->data) == i);
call    0 returned 100%
        -: 1282:
       10: 1283:      if ((i % 2) != 0)
branch  0 taken 50% (fallthrough)
branch  1 taken 50%
        5: 1284:        _dbus_list_remove_link (&list1, link1);
call    0 returned 100%
        -: 1285:
       10: 1286:      verify_list (&list1);
call    0 returned 100%
        -: 1287:      
       10: 1288:      link1 = next;
       10: 1289:      ++i;
        -: 1290:    }
        -: 1291:
        1: 1292:  _dbus_assert (all_even_values (&list1));
call    0 returned 100%
call    1 returned 100%
        1: 1293:  _dbus_list_clear (&list1);
call    0 returned 100%
        -: 1294:
        -: 1295:  /* Test copying a list */
        1: 1296:  i = 0;
       12: 1297:  while (i < 10)
branch  0 taken 91%
branch  1 taken 9% (fallthrough)
        -: 1298:    {
       10: 1299:      _dbus_list_append (&list1, _DBUS_INT_TO_POINTER (i));
call    0 returned 100%
       10: 1300:      _dbus_list_prepend (&list2, _DBUS_INT_TO_POINTER (i));
call    0 returned 100%
       10: 1301:      ++i;
        -: 1302:    }
        -: 1303:
        -: 1304:  /* bad pointers, because they are allowed in the copy dest */
        1: 1305:  copy1 = _DBUS_INT_TO_POINTER (0x342234);
        1: 1306:  copy2 = _DBUS_INT_TO_POINTER (23);
        -: 1307:  
        1: 1308:  _dbus_list_copy (&list1, &copy1);
call    0 returned 100%
        1: 1309:  verify_list (&list1);
call    0 returned 100%
        1: 1310:  verify_list (&copy1);
call    0 returned 100%
        1: 1311:  _dbus_assert (lists_equal (&list1, &copy1));
call    0 returned 100%
call    1 returned 100%
        -: 1312:  
        1: 1313:  _dbus_list_copy (&list2, &copy2);
call    0 returned 100%
        1: 1314:  verify_list (&list2);
call    0 returned 100%
        1: 1315:  verify_list (&copy2);
call    0 returned 100%
        1: 1316:  _dbus_assert (lists_equal (&list2, &copy2));
call    0 returned 100%
call    1 returned 100%
        -: 1317:
        -: 1318:  /* Now test copying empty lists */
        1: 1319:  _dbus_list_clear (&list1);
call    0 returned 100%
        1: 1320:  _dbus_list_clear (&list2);
call    0 returned 100%
        1: 1321:  _dbus_list_clear (&copy1);
call    0 returned 100%
        1: 1322:  _dbus_list_clear (&copy2);
call    0 returned 100%
        -: 1323:  
        -: 1324:  /* bad pointers, because they are allowed in the copy dest */
        1: 1325:  copy1 = _DBUS_INT_TO_POINTER (0x342234);
        1: 1326:  copy2 = _DBUS_INT_TO_POINTER (23);
        -: 1327:  
        1: 1328:  _dbus_list_copy (&list1, &copy1);
call    0 returned 100%
        1: 1329:  verify_list (&list1);
call    0 returned 100%
        1: 1330:  verify_list (&copy1);
call    0 returned 100%
        1: 1331:  _dbus_assert (lists_equal (&list1, &copy1));
call    0 returned 100%
call    1 returned 100%
        -: 1332:  
        1: 1333:  _dbus_list_copy (&list2, &copy2);
call    0 returned 100%
        1: 1334:  verify_list (&list2);
call    0 returned 100%
        1: 1335:  verify_list (&copy2);
call    0 returned 100%
        1: 1336:  _dbus_assert (lists_equal (&list2, &copy2));
call    0 returned 100%
call    1 returned 100%
        -: 1337:
        1: 1338:  _dbus_list_clear (&list1);
call    0 returned 100%
        1: 1339:  _dbus_list_clear (&list2);
call    0 returned 100%
        -: 1340:  
        -: 1341:  /* insert_before on empty list */
        1: 1342:  _dbus_list_insert_before (&list1, NULL,
call    0 returned 100%
        -: 1343:                            _DBUS_INT_TO_POINTER (0));
        1: 1344:  verify_list (&list1);
call    0 returned 100%
        -: 1345:
        -: 1346:  /* inserting before first element */
        1: 1347:  _dbus_list_insert_before (&list1, list1,
call    0 returned 100%
        -: 1348:                            _DBUS_INT_TO_POINTER (2));
        1: 1349:  verify_list (&list1);
call    0 returned 100%
        1: 1350:  _dbus_assert (is_descending_sequence (&list1));
call    0 returned 100%
call    1 returned 100%
        -: 1351:
        -: 1352:  /* inserting in the middle */
        1: 1353:  _dbus_list_insert_before (&list1, list1->next,
call    0 returned 100%
        -: 1354:                            _DBUS_INT_TO_POINTER (1));
        1: 1355:  verify_list (&list1);
call    0 returned 100%
        1: 1356:  _dbus_assert (is_descending_sequence (&list1));  
call    0 returned 100%
call    1 returned 100%
        -: 1357:
        -: 1358:  /* using insert_before to append */
        1: 1359:  _dbus_list_insert_before (&list1, NULL,
call    0 returned 100%
        -: 1360:                            _DBUS_INT_TO_POINTER (-1));
        1: 1361:  verify_list (&list1);
call    0 returned 100%
        1: 1362:  _dbus_assert (is_descending_sequence (&list1));
call    0 returned 100%
call    1 returned 100%
        -: 1363:  
        1: 1364:  _dbus_list_clear (&list1);
call    0 returned 100%
        -: 1365:
        -: 1366:  /* insert_after on empty list */
        1: 1367:  _dbus_list_insert_after (&list1, NULL,
call    0 returned 100%
        -: 1368:                           _DBUS_INT_TO_POINTER (0));
        1: 1369:  verify_list (&list1);
call    0 returned 100%
        -: 1370:
        -: 1371:  /* inserting after first element */
        1: 1372:  _dbus_list_insert_after (&list1, list1,
call    0 returned 100%
        -: 1373:                           _DBUS_INT_TO_POINTER (1));
        1: 1374:  verify_list (&list1);
call    0 returned 100%
        1: 1375:  _dbus_assert (is_ascending_sequence (&list1));
call    0 returned 100%
call    1 returned 100%
        -: 1376:
        -: 1377:  /* inserting at the end */
        1: 1378:  _dbus_list_insert_after (&list1, list1->next,
call    0 returned 100%
        -: 1379:                           _DBUS_INT_TO_POINTER (2));
        1: 1380:  verify_list (&list1);
call    0 returned 100%
        1: 1381:  _dbus_assert (is_ascending_sequence (&list1));
call    0 returned 100%
call    1 returned 100%
        -: 1382:
        -: 1383:  /* using insert_after to prepend */
        1: 1384:  _dbus_list_insert_after (&list1, NULL,
call    0 returned 100%
        -: 1385:                           _DBUS_INT_TO_POINTER (-1));
        1: 1386:  verify_list (&list1);
call    0 returned 100%
        1: 1387:  _dbus_assert (is_ascending_sequence (&list1));
call    0 returned 100%
call    1 returned 100%
        -: 1388:  
        1: 1389:  _dbus_list_clear (&list1);
call    0 returned 100%
        -: 1390:
        -: 1391:  /* using remove_last */
        1: 1392:  _dbus_list_append (&list1, _DBUS_INT_TO_POINTER (2));
call    0 returned 100%
        1: 1393:  _dbus_list_append (&list1, _DBUS_INT_TO_POINTER (1));
call    0 returned 100%
        1: 1394:  _dbus_list_append (&list1, _DBUS_INT_TO_POINTER (3));
call    0 returned 100%
        -: 1395:
        1: 1396:  _dbus_list_remove_last (&list1, _DBUS_INT_TO_POINTER (2));
call    0 returned 100%
        -: 1397:  
        1: 1398:  verify_list (&list1);
call    0 returned 100%
        1: 1399:  _dbus_assert (is_ascending_sequence (&list1));
call    0 returned 100%
call    1 returned 100%
        -: 1400:  
        1: 1401:  _dbus_list_clear (&list1);
call    0 returned 100%
        -: 1402:  
        1: 1403:  return TRUE;
        -: 1404:}
        -: 1405:
        -: 1406:#endif