This file is indexed.

/usr/include/CLAM/PhantomBuffer.hxx is in libclam-dev 1.4.0-5build1.

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
/*
 * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
 *                         UNIVERSITAT POMPEU FABRA
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#ifndef _PHANTOM_BUFFER_H
#define _PHANTOM_BUFFER_H


#include <vector>
#include <iostream>
#include "Assert.hxx"

namespace CLAM {

	template<class T>
	class PhantomBuffer 
	{
	public:
		PhantomBuffer();
		T*   Read(unsigned int pos, unsigned int size);

		/**
			Updates the beginning or phantom zone corresponding with 'symetric'
			of the specifyed window
		 	/see UpdatePhantom
	 	 */
		void Touch(unsigned int pos, unsigned int size);

		/**
			Copies an array into the buffer and updates (touches) the
			'repeated' data (beginning or phantom)
			/see Touch
		**/
		void Write(unsigned int pos, unsigned int size,const T* data);

		unsigned LogicalSize() const {return mLogicalSize;}
		
		unsigned int PhantomSize() const { return mBuffer.size() - mLogicalSize; }

		void Resize(unsigned int size,
		            unsigned int phantom,
		            unsigned int insert_pos);
	
		/**
			For debugging purposes. Checks that:
			logical / phantom sizes are consistents and
			'repeated' data is consistent
			/see Touch
		**/
		void FulfilsInvariant() const;

	private:
		/**
			Updates the phantom zone corresponding with 'symetric' of the specifyed window
			/see UpdateBeginning
	 	*/
		void UpdatePhantom(unsigned int pos, unsigned int size);
		/**
			Updates the beginning zone corresponding with 'symetric' of the specifyed window
			/see UpdatePhantom
	 	c*/
		void UpdateBeginning(unsigned int pos, unsigned int size);

		unsigned int AllocatedSize() const
		{ 
			return mBuffer.size(); 
		}

	
		// attributes
		std::vector<T> mBuffer;
		unsigned mLogicalSize;
	};

	
	template<class T>
	PhantomBuffer<T>::PhantomBuffer()
		: mLogicalSize(0) 
	{}


	template<class T>
	void PhantomBuffer<T>::UpdatePhantom(unsigned int pos, unsigned int size)
	{
		CLAM_DEBUG_ASSERT(pos+size <= PhantomSize(),
		                 "PhantomBuffer::UpdatePhantom():"
		                 "Requested region falls outside phantom zone");
		unsigned int s,d;
		for (s=pos, d=mLogicalSize+pos; s<pos+size; s++, d++)
			mBuffer[d] = mBuffer[s];
	}

	template<class T>
	void PhantomBuffer<T>::UpdateBeginning(unsigned int pos, unsigned int size)
	{
		CLAM_DEBUG_ASSERT(pos+size <= PhantomSize(),
		                 "PhantomBuffer::UpdateBeginning():"
		                 "Requested region falls outside beginning zone");
		unsigned int s,d;
		for (d=pos, s=mLogicalSize+pos; d<size; d++, s++)
			mBuffer[d] = mBuffer[s];
	}


	template<class T>
	void PhantomBuffer<T>::Resize(unsigned int newLogicalSize, unsigned int newPhantomSize, unsigned int insertionPos)
	{
		CLAM_ASSERT(insertionPos <= LogicalSize(),
		           "PhantomBuffer::Resize(): "
		           "Insertion position can not be greater than previous size.");
		CLAM_ASSERT(newPhantomSize <= newLogicalSize,
		           "PhantomBuffer::Resize(): Phantom Size can not be greater than size.");

		if ( newLogicalSize <= LogicalSize() )
			return;

		CLAM_ASSERT(newPhantomSize >= PhantomSize(),
		           "PhantomBuffer::Resize(): PhantomSize can not be decreased.");

		unsigned int logicalElementsToInsert = newLogicalSize - LogicalSize();
		unsigned int phantomElementsToInsert = newPhantomSize - PhantomSize();

		typename std::vector<T>::iterator it = mBuffer.begin();
		it += insertionPos;
		mBuffer.insert(it, logicalElementsToInsert, T());

		mBuffer.insert( mBuffer.end(), phantomElementsToInsert,  T());
		//TODO update phantom

		mLogicalSize = newLogicalSize;
	}


	template<class T>
	T* PhantomBuffer<T>::Read(unsigned int pos, unsigned int size)
	{
		CLAM_DEBUG_ASSERT( (pos+size-1) <= ( AllocatedSize() ),
		                  "PhantomBuffer::Read(): Position outside bounds");
		return &mBuffer[pos];
	}


	template<class T>
	void PhantomBuffer<T>::Touch(unsigned int pos, unsigned int size)
	{
		CLAM_DEBUG_ASSERT( (pos+size) <= ( AllocatedSize() ),
		                  "PhantomBuffer::Write(): Position outside bounds");
		unsigned int writen_area_end = pos+size;

		if (writen_area_end > mLogicalSize)
		{
			unsigned int update_start;
			if (mLogicalSize > pos)
				update_start = 0;
			else
				update_start = pos-mLogicalSize;
			UpdateBeginning(update_start, writen_area_end - mLogicalSize - update_start);
		}
		else if ( pos < PhantomSize() )
		{
			int update_end;
			if (PhantomSize() < writen_area_end )
				update_end = PhantomSize();
			else
				update_end = writen_area_end;
			UpdatePhantom(pos,update_end-pos);
		}
	}


	template<class T>
	void PhantomBuffer<T>::Write(unsigned int pos, unsigned int size,const T* data)
	{
		CLAM_DEBUG_ASSERT( (pos+size) <= ( AllocatedSize() ),
		                  "PhantomBuffer::Write(): Position outside bounds");
		unsigned int s,d;

		for (s=0, d=pos; s<size; s++, d++)
			mBuffer[d] = data[s];
		Touch(pos,size);
	}


	template<class T>
	void PhantomBuffer<T>::FulfilsInvariant() const
	{
		CLAM_ASSERT(mBuffer.size() == AllocatedSize(),
		           "PhantomBuffer<T>::FulfilsInvariant(): "
		           "internal vector size unconsistency");
		CLAM_ASSERT(PhantomSize() <= mLogicalSize,
		           "PhantomBuffer<T>::FulfilsInvariant(): "
		           "Phantom size biger than logical size");
		unsigned int i;
		for (i=0; i<PhantomSize(); i++)
			CLAM_ASSERT(mBuffer[i] == mBuffer[i+mLogicalSize],
			            "PhantomBuffer<T>::FulfilsInvariant(): "
			            "Phantom data is unconsistent!");

	}

} // namespace CLAM

#endif