This file is indexed.

/usr/include/claw/impl/smart_ptr.tpp is in libclaw-dev 1.7.4-2.

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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
/*
  CLAW - a C++ Library Absolutely Wonderful

  CLAW is a free library without any particular aim but being useful to 
  anyone.

  Copyright (C) 2005-2011 Julien Jorge

  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.1 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

  contact: julien.jorge@gamned.org
*/
/**
 * \file smart_ptr.tpp
 * \brief Implementation of the claw::memory::smart_ptr class.
 * \author Julien Jorge
 */
#include <cassert>
#include <cstdlib>

/*----------------------------------------------------------------------------*/
/**
 * \brief Default constructor.
 */
template<typename T>
claw::memory::smart_ptr<T>::smart_ptr()
  : m_ref_count(NULL), m_ptr(NULL)
{

} // smart_ptr::smart_ptr()

/*----------------------------------------------------------------------------*/
/**
 * \brief Constructor from a pointer.
 * \param data Pointer on the data.
 *
 * \b Warning: this constructor allows expressions like
 *
 * <tt>int a; smart_ptr<int> p(&a);</tt>
 *
 * Nevertheless, you should never fo that.
 */
template<typename T>
claw::memory::smart_ptr<T>::smart_ptr( pointer data )
  : m_ref_count(NULL), m_ptr(NULL)
{
  if (data)
    {
      m_ref_count = new unsigned int(1);
      m_ptr = data;
    }
} // smart_ptr::smart_ptr() [pointer]

/*----------------------------------------------------------------------------*/
/**
 * \brief Copy constructor.
 * \param that The smart_pointer to copy.
 */
template<typename T>
claw::memory::smart_ptr<T>::smart_ptr( const self_type& that )
{
  copy( that );
} // smart_ptr::smart_ptr() [copy]

/*----------------------------------------------------------------------------*/
/**
 * \brief Destructor. The memory is freed only if no more smart_ptr point on it.
 */
template<typename T>
claw::memory::smart_ptr<T>::~smart_ptr()
{
  release();
} // smart_ptr::~smart_ptr()

/*----------------------------------------------------------------------------*/
/**
 * \brief Assignment operator.
 * \param that The smart_ptr to copy.
 */
template<typename T>
typename claw::memory::smart_ptr<T>::self_type&
claw::memory::smart_ptr<T>::operator=( const self_type& that )
{
  if ( &that != this )
    {
      release();
      copy( that );
    }

  return *this;
} // smart_ptr::operator=()

/*----------------------------------------------------------------------------*/
/**
 * \brief Equality operator.
 * \param that The pointer to compare to.
 * \return !(*this < that) && !(that < *this).
 */
template<typename T>
bool claw::memory::smart_ptr<T>::operator==( const self_type& that ) const
{
  return !(*this < that) && !(that < *this);
} // smart_ptr::operator==()

/*----------------------------------------------------------------------------*/
/**
 * \brief Disequality operator.
 * \param that The pointer to compare to.
 * \return (*this < that) || (that < *this).
 */
template<typename T>
bool claw::memory::smart_ptr<T>::operator!=( const self_type& that ) const
{
  return (*this < that) || (that < *this);
} // smart_ptr::operator!=()

/*----------------------------------------------------------------------------*/
/**
 * \brief "Less than" operator.
 * \param that The pointer to compare to.
 * \return True if the address pointed by \a this is lower than the address
 *         pointed by \a that.
 */
template<typename T>
bool claw::memory::smart_ptr<T>::operator<( const self_type& that ) const
{
  return m_ptr < that.m_ptr;
} // smart_ptr::operator<()

/*----------------------------------------------------------------------------*/
/**
 * \brief "Less or equal" operator.
 * \param that The pointer to compare to.
 * \return !(that < *this).
 */
template<typename T>
bool claw::memory::smart_ptr<T>::operator<=( const self_type& that ) const
{
  return !(that < *this);
} // smart_ptr::operator<=()

/*----------------------------------------------------------------------------*/
/**
 * \brief "Greater than" operator.
 * \param that The pointer to compare to.
 * \return \a that < *this.
 */
template<typename T>
bool claw::memory::smart_ptr<T>::operator>( const self_type& that ) const
{
  return that < *this;
} // smart_ptr::operator>()

/*----------------------------------------------------------------------------*/
/**
 * \brief "Greater or equal" operator.
 * \param that The pointer to compare to.
 * \return !(*this < that).
 */
template<typename T>
bool claw::memory::smart_ptr<T>::operator>=( const self_type& that ) const
{
  return !(*this < that);
} // smart_ptr::operator>=()

/*----------------------------------------------------------------------------*/
/**
 * \brief Dereference operator.
 */
template<typename T>
typename claw::memory::smart_ptr<T>::pointer
claw::memory::smart_ptr<T>::operator->()
{
  return m_ptr;
} // smart_ptr::operator->()

/*----------------------------------------------------------------------------*/
/**
 * \brief Dereference operator.
 */
template<typename T>
typename claw::memory::smart_ptr<T>::pointer
claw::memory::smart_ptr<T>::operator->() const
{
  return m_ptr;
} // smart_ptr::operator->()

/*----------------------------------------------------------------------------*/
/**
 * \brief Dereference operator.
 */
template<typename T>
typename claw::memory::smart_ptr<T>::reference
claw::memory::smart_ptr<T>::operator*()
{
  return *m_ptr;
} // smart_ptr::operator*()

/*----------------------------------------------------------------------------*/
/**
 * \brief Dereference operator.
 */
template<typename T>
typename claw::memory::smart_ptr<T>::reference
claw::memory::smart_ptr<T>::operator*() const
{
  return *m_ptr;
} // smart_ptr::operator*()

/*----------------------------------------------------------------------------*/
/**
 * \brief Copy a smart_ptr.
 * \param that The smart_pointer to copy.
 */
template<typename T>
void claw::memory::smart_ptr<T>::copy( const self_type& that )
{
  assert( this != &that );

  m_ref_count = that.m_ref_count;
  m_ptr = that.m_ptr;

  if (m_ref_count)
    ++(*m_ref_count);
} // smart_ptr::copy()

/*----------------------------------------------------------------------------*/
/**
 * \brief Release the allocated memory.
 *
 * The memory is release only if no more smart_ptr point on it.
 */
template<typename T>
void claw::memory::smart_ptr<T>::release()
{
  if (m_ref_count)
    if ( *m_ref_count )
      {
	--(*m_ref_count);

	if ( !(*m_ref_count) )
	  {
	    delete m_ptr;
	    delete m_ref_count;
	      
	    m_ref_count = NULL;
	  }
	  
	m_ptr = NULL;
      }
} // smart_ptr::release()