This file is indexed.

/usr/include/zipios++/simplesmartptr.h is in libzipios++-dev 0.1.5.9+cvs.2007.04.28-5.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#ifndef SIMPLESMARTPTR_H
#define SIMPLESMARTPTR_H

#include "zipios++/zipios-config.h"

namespace zipios {

/** SimpleSmartPointer is a simple reference counting smart pointer
    template. The type pointed to must keep a reference count that is
    accessible through the two methods void ref() const and unsigned
    int unref() const. The type must also handle the reference count
    properly. The easiest way to do that is to use the ReferenceCount
    template class. */
template< class Type >
class SimpleSmartPointer {
public:
  Type *operator-> () const { return _p ;  }

  Type &operator* ()  const { return *_p ; }

  SimpleSmartPointer( Type *p = 0 ) : _p( p ) { ref() ; }

  template< class T2 > SimpleSmartPointer( const SimpleSmartPointer< T2 > &src ) 
    : _p( src.get() ) { ref() ; }

  SimpleSmartPointer( const SimpleSmartPointer &src ) : _p( src.get() ) { 
    ref() ; 
  }

  ~SimpleSmartPointer () { if ( unref() == 0 ) deleteIt() ; }

  template< class T2 > 
  SimpleSmartPointer &operator= ( const SimpleSmartPointer< T2 > &src ) {
    ref( src.get() ) ;
    if ( unref() == 0 )
      deleteIt() ;
    _p = src.get() ;
    return *this ;
  }

  SimpleSmartPointer &operator= ( const SimpleSmartPointer &src ) {
    ref( src.get() ) ;
    if ( unref() == 0 )
      deleteIt() ;
    _p = src.get() ;
    return *this ;
  }

  SimpleSmartPointer &operator=( Type *src ) {
    _p = src ;
    ref() ; 
    return *this ;
  }

  bool operator== ( const Type *p )                const { return _p == p     ; }
  bool operator!= ( const Type *p )                const { return _p != p     ; }
  bool operator== ( const SimpleSmartPointer &sp ) const { return _p == sp.get() ; }
  bool operator!= ( const SimpleSmartPointer &sp ) const { return _p != sp.get() ; }
  bool operator!  ()                               const { return ! _p        ; }
  // This next method is inspired by iostream, and is for use with 
  // if ( some_smart_pointer ).
  operator void*() const { return _p ? (void *)(-1) : (void *)(0) ; }

  Type *get() const { return _p ; }

  /** Returns the reference count - For debugging purposes. */
  unsigned int getReferenceCount() const { return _p->getReferenceCount(); }


private:
  template< class T2 >
  void ref( const T2 *ptr ) { if ( ptr ) ptr->ref() ; }

  void ref() const { if ( _p ) _p->ref() ; }
  unsigned int unref() const {
    if ( _p )
      return _p->unref();
    else
      return 0 ;
  }
  void deleteIt() {
//      if( _p )
//        cerr << "SimpleSmartPointer: Deleting object!" << endl ;
    delete _p ;
  }
  Type *_p ;
};


/** ReferenceCount is useful to ensure proper handling of the
    reference count for (objects of) classes handled through a
    SimpleSmartPointer. Subclassing ReferenceCount is all a class
    needs to become ready for being handled by
    SimpleSmartPointer. Another way is to add a ReferenceCount member
    variable to a class and write two methods 'void ref() const' and
    'unsigned int unref() const' that invoke the same methods in the
    ReferenceCount variable. */
template< class Type >
class ReferenceCount {
  /** SimpleSmartPointer needs to be a friend to invoke the private
      ref() and unref() methods.  */
  friend class SimpleSmartPointer< Type > ;
  friend class SimpleSmartPointer< const Type > ;
  /** Type also needs to be a friend to invoke the private ref() and
      unref() methods, in case Type doesn't want to inherit
      ReferenceCount and thus needs to invoke ref() and unref()
      through forwarding member functions. */
  //
  //  Originally the following template parameter was made a friend.
  //  This is not allowed by the standard so comment it out:
  //
  // friend Type ;
  //
  //  Initially hack things by making the necessary classes friends
  //  even though we don't know really which they are.  This is an
  //  Hideous Hack.
  friend class FileEntry ;
  friend class Bogus ;
  
public:
  /** Constructor intializes count to zero. */
  ReferenceCount() : _ref_count( 0 ) {}

  /** Copy-constructor intializes count to zero. It doesn't copy it
      from src. */
  ReferenceCount( const ReferenceCount &src ) : _ref_count( 0 ) {}

  /** The assignment operator doesn't copy the reference count, it
      leaves it unchanged.  */
  const ReferenceCount &operator= ( const ReferenceCount &src ) { return *this; }
private:

  /** Increases the reference count. */
  void ref() const           { ++_ref_count ;        }

  /** Decreases the reference count. */
  unsigned int unref() const { return --_ref_count ; }

  /** Returns the reference count - For debugging purposes. */
  unsigned int getReferenceCount() const { return _ref_count; }

  /** Holds the actual reference count */
  mutable unsigned short _ref_count ;
};



} // namespace

#endif

/** \file
    Header file that defines SimpleSmartPointer and ReferenceCount.
*/

/*
  Zipios++ - a small C++ library that provides easy access to .zip files.
  Copyright (C) 2000  Thomas Søndergaard
  
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2 of the License, or (at your option) any later version.
  
  This library 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
  Lesser General Public License for more details.
  
  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
*/