This file is indexed.

/usr/include/gnash/SimpleBuffer.h is in gnash-dev 0.8.11~git20160109-1build1.

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
// 
//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
//   Free Software Foundation, Inc
// 
// 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

#ifndef GNASH_SIMPLEBUFFER_H
#define GNASH_SIMPLEBUFFER_H


#include <cstdint> // for std::uint8_t
#include <algorithm> // for std::copy
#include <memory>
#include <cassert>


namespace gnash {

/// A simple buffer of bytes
//
/// This class is fully inlined and just aiming to provide RIIA
/// and unified view of memory buffers.
/// It is a kind of a std::vector with a reduced interface
/// in the intentions of the author.
///
class SimpleBuffer {

public:

	/// Construct a SimpleBuffer with an optional initial capacity
	//
	/// @param capacity
	///	The initial buffer capacity. This is the amount of
	///	bytes you can append to the buffer before a new reallocation
	///	will occur.
	///
	SimpleBuffer(size_t capacity=0)
		:
		_size(0),
		_capacity(capacity)
	{
		if ( _capacity )
		{
			_data.reset(new std::uint8_t[_capacity]);
		}
	}

        /// Move constructor.
        SimpleBuffer(SimpleBuffer&&) = default;

        /// Copy (construction) not allowed.
        SimpleBuffer(const SimpleBuffer& b) = delete;
        SimpleBuffer& operator= (const SimpleBuffer& b) = delete;

        /// Move assignment is okay.
        SimpleBuffer& operator= (SimpleBuffer&&) = default;


	/// Return true if buffer is empty
	bool empty() const { return _size==0; }

	/// Return size of the buffer
	size_t size() const { return _size; }

	/// Return capacity of the buffer
	size_t capacity() const { return _capacity; }

	/// Get a pointer to start of data. May be NULL if size==0.
	std::uint8_t* data() { return _data.get(); }

	/// Get a pointer to start of data. May be NULL if size==0.
	const std::uint8_t* data() const { return _data.get(); }

	/// Resize the buffer
	void resize(size_t newSize)
	{
		reserve(newSize); // will set capacity
		_size = newSize;
	}

	/// Ensure at least 'newCapacity' bytes are allocated for this buffer
	void reserve(size_t newCapacity)
	{
		if ( _capacity >= newCapacity ) return;

		// TODO: use smalles power of 2 bigger then newCapacity
		_capacity = std::max(newCapacity, _capacity*2);

		std::unique_ptr<std::uint8_t[]> tmp;
		tmp.swap(_data);
		
		_data.reset(new std::uint8_t[_capacity]);

		if ( tmp.get() )
		{
			if ( _size ) std::copy(tmp.get(), tmp.get()+_size, _data.get());
		}
	}

	/// Append data to the buffer
	//
	/// The buffer will be appropriately resized to have space for
	/// the incoming data. The data will be copied.
	///
	/// @param inData
	///	Data to append. Will be copied.
	///
	/// @param size
	///	Size of data to append
	///
	void append(const void* inData, size_t size)
	{
		const std::uint8_t* newData =
            reinterpret_cast<const std::uint8_t*>(inData);
		size_t curSize = _size;
		resize(curSize+size);
		std::copy(newData, newData+size, _data.get()+curSize);
		assert(_size == curSize+size);
	}

	/// Append a byte to the buffer
	//
	/// The buffer will be appropriately resized to have space.
	///
	/// @param b
	///	Byte to append.
	///
	void appendByte(const std::uint8_t b)
	{
		resize(_size + 1);
		_data[_size - 1] = b;
	}

	/// Append 2 bytes to the buffer
	//
	/// The buffer will be appropriately resized to have space.
	///
	/// @param s
	///	Short to append. Will be appended in network order. ie
	///  with high order byte first.
	///
	void appendNetworkShort(const std::uint16_t s)
	{
		resize(_size + 2);
		_data[_size - 2] = s >> 8;
		_data[_size - 1] = s & 0xff;
	}

	/// Append 4 bytes to the buffer
	//
	/// The buffer will be appropriately resized to have space.
	///
	/// @param l
	///	Long to append. Will be appended in network order. ie
	///  with high order bytes first.
	///
	void appendNetworkLong(const std::uint32_t l)
	{
		resize(_size + 4);
		_data[_size - 4] = l >> 24;
		_data[_size - 3] = (l >> 16) & 0xff;
		_data[_size - 2] = (l >> 8) & 0xff;
		_data[_size - 1] = l & 0xff;
	}

	/// Append data to the buffer
	//
	/// The buffer will be appropriately resized to have space for
	/// the incoming data. The data will be copied.
	///
	/// @param buf
	///	SimpleBuffer containing data to append
	///
	void append(const SimpleBuffer& buf)
	{
		size_t incomingDataSize = buf.size();
		const std::uint8_t* incomingData = buf.data();
		append(incomingData, incomingDataSize);
	}

private:
	size_t _size;
	size_t _capacity;

	std::unique_ptr<std::uint8_t[]> _data;
};


}	// namespace gnash

#endif // GNASH_SIMPLEBUFFER_H