LCOV - code coverage report
Current view: top level - ccache - hashtable_itr.h (source / functions) Hit Total Coverage
Test: ccache.lcov.info Lines: 0 4 0.0 %
Date: 2015-06-29 Functions: 0 2 0.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* Copyright (C) 2002, 2004 Christopher Clark <firstname.lastname@cl.cam.ac.uk> */
       2                 :            : 
       3                 :            : #ifndef __HASHTABLE_ITR_CWC22__
       4                 :            : #define __HASHTABLE_ITR_CWC22__
       5                 :            : #include "hashtable.h"
       6                 :            : #include "hashtable_private.h" /* needed to enable inlining */
       7                 :            : 
       8                 :            : /*****************************************************************************/
       9                 :            : /* This struct is only concrete here to allow the inlining of two of the
      10                 :            :  * accessor functions. */
      11                 :            : struct hashtable_itr
      12                 :            : {
      13                 :            :     struct hashtable *h;
      14                 :            :     struct entry *e;
      15                 :            :     struct entry *parent;
      16                 :            :     unsigned int index;
      17                 :            : };
      18                 :            : 
      19                 :            : 
      20                 :            : /*****************************************************************************/
      21                 :            : /* hashtable_iterator
      22                 :            :  */
      23                 :            : 
      24                 :            : struct hashtable_itr *
      25                 :            : hashtable_iterator(struct hashtable *h);
      26                 :            : 
      27                 :            : /*****************************************************************************/
      28                 :            : /* hashtable_iterator_key
      29                 :            :  * - return the value of the (key,value) pair at the current position */
      30                 :            : 
      31                 :            : #ifdef HAVE_EXTERN_INLINE
      32                 :            : extern inline void *
      33                 :          0 : hashtable_iterator_key(struct hashtable_itr *i)
      34                 :            : {
      35                 :          0 :     return i->e->k;
      36                 :            : }
      37                 :            : #else
      38                 :            : void *
      39                 :            : hashtable_iterator_key(struct hashtable_itr *i);
      40                 :            : #endif
      41                 :            : 
      42                 :            : /*****************************************************************************/
      43                 :            : /* value - return the value of the (key,value) pair at the current position */
      44                 :            : 
      45                 :            : #ifdef HAVE_EXTERN_INLINE
      46                 :            : extern inline void *
      47                 :          0 : hashtable_iterator_value(struct hashtable_itr *i)
      48                 :            : {
      49                 :          0 :     return i->e->v;
      50                 :            : }
      51                 :            : #else
      52                 :            : void *
      53                 :            : hashtable_iterator_value(struct hashtable_itr *i);
      54                 :            : #endif
      55                 :            : 
      56                 :            : /*****************************************************************************/
      57                 :            : /* advance - advance the iterator to the next element
      58                 :            :  *           returns zero if advanced to end of table */
      59                 :            : 
      60                 :            : int
      61                 :            : hashtable_iterator_advance(struct hashtable_itr *itr);
      62                 :            : 
      63                 :            : /*****************************************************************************/
      64                 :            : /* remove - remove current element and advance the iterator to the next element
      65                 :            :  *          NB: if you need the value to free it, read it before
      66                 :            :  *          removing. ie: beware memory leaks!
      67                 :            :  *          returns zero if advanced to end of table */
      68                 :            : 
      69                 :            : int
      70                 :            : hashtable_iterator_remove(struct hashtable_itr *itr);
      71                 :            : 
      72                 :            : /*****************************************************************************/
      73                 :            : /* search - overwrite the supplied iterator, to point to the entry
      74                 :            :  *          matching the supplied key.
      75                 :            :             h points to the hashtable to be searched.
      76                 :            :  *          returns zero if not found. */
      77                 :            : int
      78                 :            : hashtable_iterator_search(struct hashtable_itr *itr,
      79                 :            :                           struct hashtable *h, void *k);
      80                 :            : 
      81                 :            : #define DEFINE_HASHTABLE_ITERATOR_SEARCH(fnname, keytype) \
      82                 :            : int fnname (struct hashtable_itr *i, struct hashtable *h, keytype *k) \
      83                 :            : { \
      84                 :            :     return (hashtable_iterator_search(i,h,k)); \
      85                 :            : }
      86                 :            : 
      87                 :            : 
      88                 :            : 
      89                 :            : #endif /* __HASHTABLE_ITR_CWC22__*/
      90                 :            : 
      91                 :            : /*
      92                 :            :  * Copyright (c) 2002, 2004, Christopher Clark
      93                 :            :  * All rights reserved.
      94                 :            :  * 
      95                 :            :  * Redistribution and use in source and binary forms, with or without
      96                 :            :  * modification, are permitted provided that the following conditions
      97                 :            :  * are met:
      98                 :            :  * 
      99                 :            :  * * Redistributions of source code must retain the above copyright
     100                 :            :  * notice, this list of conditions and the following disclaimer.
     101                 :            :  * 
     102                 :            :  * * Redistributions in binary form must reproduce the above copyright
     103                 :            :  * notice, this list of conditions and the following disclaimer in the
     104                 :            :  * documentation and/or other materials provided with the distribution.
     105                 :            :  * 
     106                 :            :  * * Neither the name of the original author; nor the names of any contributors
     107                 :            :  * may be used to endorse or promote products derived from this software
     108                 :            :  * without specific prior written permission.
     109                 :            :  * 
     110                 :            :  * 
     111                 :            :  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     112                 :            :  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     113                 :            :  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     114                 :            :  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER
     115                 :            :  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     116                 :            :  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     117                 :            :  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     118                 :            :  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
     119                 :            :  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
     120                 :            :  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     121                 :            :  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     122                 :            : */

Generated by: LCOV version 1.9