This file is indexed.

/usr/include/InsightToolkit/Common/itkObjectStore.txx is in libinsighttoolkit3-dev 3.20.1-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
/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    itkObjectStore.txx
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) Insight Software Consortium. All rights reserved.
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef __itkObjectStore_txx
#define __itkObjectStore_txx

#include "itkObjectStore.h"

namespace itk {

template <class TObjectType>
ObjectStore<TObjectType>
::ObjectStore()
{
  m_Size  = 0;
  m_LinearGrowthSize = 1024;
  m_GrowthStrategy = EXPONENTIAL_GROWTH;
}

template <class TObjectType>
ObjectStore<TObjectType>
::~ObjectStore()
{
  this->Clear();
}

template <class TObjectType>
void
ObjectStore<TObjectType>
::Reserve(::size_t n)
{
  // No need to grow? Do nothing.
  if ( n <= m_Size ) return;

  // Need to grow.  Allocate a new block of memory and copy that block's
  // pointers into the m_FreeList.  Updates m_Size appropriately.
  MemoryBlock new_block( n - m_Size );
  m_Store.push_back( new_block );

  m_FreeList.reserve(n);
  for (ObjectType *ptr = new_block.Begin;
       ptr < new_block.Begin + new_block.Size; ptr++)
    {      m_FreeList.push_back(ptr);    }
  m_Size += ( n - m_Size );
}

template <class TObjectType>
typename ObjectStore<TObjectType>::ObjectType *
ObjectStore<TObjectType>
::Borrow()
{
  ObjectType *p;
  if (m_FreeList.empty() ) // must allocate more memory
    {
    this->Reserve( m_Size + this->GetGrowthSize() );
    }
  p = m_FreeList.back();
  m_FreeList.pop_back();
  return p;

  //To do: This method will need to decrement counters in the memory blocks so
  //that blocks know when they can be deleted.
}

template <class TObjectType>
void
ObjectStore<TObjectType>
::Return(ObjectType *p)
{
  // For speed, does no checking.
  m_FreeList.push_back(p);
  
  //  if ( m_FreeList.size() != m_Size )
  //    {  m_FreeList.push_back(p); }
  // else object has been used incorrectly

  // To do:
  // Eventually this method will have to increment counters in the memory
  // blocks so that blocks know when they can be deleted.  This will also allow
  // for checking to see if p actually belongs to this store.
  //
  // Problems could easily result if a pointer is Returned more than
  // once. Only time-wise efficient way to deal with this would be a flag in
  // the allocated memory block for each object, sort of how malloc deals with
  // it?
}

template <class TObjectType>
::size_t
ObjectStore<TObjectType>
::GetGrowthSize()
{
  switch (m_GrowthStrategy)
    {
    case LINEAR_GROWTH:
      return m_LinearGrowthSize;
      break;
    case EXPONENTIAL_GROWTH:
      if (m_Size == 0) return m_LinearGrowthSize;
      else return m_Size;
      break;
    default:
      return m_LinearGrowthSize;
    }

  // Strictly to avoid compiler warning regarding "control may reach end of
  // non-void function":
  //
  return m_LinearGrowthSize;
}

template <class TObjectType>
void
ObjectStore<TObjectType>
::Squeeze()
{
  // Not implemented yet.

}

template <class TObjectType>
void
ObjectStore<TObjectType>
::Clear()
{
  // Clear the free list.
  m_FreeList.clear();
  
  // Empty the MemoryBlock list and deallocate all memory blocks.
  while ( ! m_Store.empty() )
    {
    m_Store.back().Delete();
    m_Store.pop_back();
    }
  m_Size = 0;
}

template <class TObjectType>
void
ObjectStore<TObjectType>
::PrintSelf(std::ostream& os, Indent indent) const
{
  Superclass::PrintSelf(os,indent);
  
  os << indent << "m_GrowthStrategy: " << m_GrowthStrategy << std::endl;
  os << indent << "m_Size: " << m_Size << std::endl;
  os << indent << "m_LinearGrowthSize: " << static_cast<unsigned long>( m_LinearGrowthSize ) << std::endl;
  os << indent << "Free list size: " << static_cast<unsigned long>( m_FreeList.size() ) << std::endl;
  os << indent << "Free list capacity: " << static_cast<unsigned long>( m_FreeList.capacity() ) << std::endl;
  os << indent << "Number of blocks in store: " << static_cast<unsigned long>( m_Store.size() ) << std::endl;
}

} // end namespace itk

#endif