This file is indexed.

/usr/include/speech_tools/EST_Chunk.h is in libestools2.1-dev 1:2.1~release-6.

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
 /************************************************************************/
 /*                                                                      */
 /*                Centre for Speech Technology Research                 */
 /*                     University of Edinburgh, UK                      */
 /*                        Copyright (c) 1997                            */
 /*                        All Rights Reserved.                          */
 /*                                                                      */
 /*  Permission is hereby granted, free of charge, to use and distribute */
 /*  this software and its documentation without restriction, including  */
 /*  without limitation the rights to use, copy, modify, merge, publish, */
 /*  distribute, sublicense, and/or sell copies of this work, and to     */
 /*  permit persons to whom this work is furnished to do so, subject to  */
 /*  the following conditions:                                           */
 /*   1. The code must retain the above copyright notice, this list of   */
 /*      conditions and the following disclaimer.                        */
 /*   2. Any modifications must be clearly marked as such.               */
 /*   3. Original authors' names are not deleted.                        */
 /*   4. The authors' names are not used to endorse or promote products  */
 /*      derived from this software without specific prior written       */
 /*      permission.                                                     */
 /*                                                                      */
 /*  THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK       */
 /*  DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING     */
 /*  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT  */
 /*  SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE    */
 /*  FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES   */
 /*  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN  */
 /*  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,         */
 /*  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF      */
 /*  THIS SOFTWARE.                                                      */
 /*                                                                      */
 /************************************************************************/
 /*                                                                      */
 /*                 Author: Richard Caley (rjc@cstr.ed.ac.uk)            */
 /*                   Date: February 1997                                */
 /* -------------------------------------------------------------------- */
 /*                                                                      */
 /* Use counted memory chunks and smart pointers to them.                */
 /*                                                                      */
 /************************************************************************/

#if ! defined(__EST_CHUNK_H__)
#define __EST_CHUNK_H__

#define HAVE_WALLOC_H (1)

#include <iostream>
using namespace std;
#include <climits>
#include <sys/types.h>

// Warn when getting a writable version of a shared chunk --
// useful for minimising copies.

/* #define __INCLUDE_CHUNK_WARNINGS__ (1) */

#if defined(__INCULDE_CHUNK_WARNINGS__)
#    define CHUNK_WARN(WHAT) do { cerr << "chunk: " <<WHAT << "\n";} while (0)
#else
#    define CHUNK_WARN(WHAT) // empty
#endif

#define __CHUNK_INLINE_AGGRESSIVELY__ (1)

#if defined(__CHUNK_INLINE_AGGRESSIVELY__)
#    define CII(BODY) BODY
#else
#    define CII(BODY) /* empty */
#endif

#define __CHUNK_USE_WALLOC__ (1)

#if __CHUNK_USE_WALLOC__

#if HAVE_WALLOC_H

# include "EST_walloc.h"

#else

#    define walloc(T,N) ((T *)malloc(sizeof(T)*(N)))
#    define wfree(P) free(P)
#    define wrealloc(P,T,N) ((T *)realloc((P),sizeof(T)*(N)))

#endif

#endif

 /************************************************************************/
 /*                                                                      */
 /* EST_Chunk is a use-counted chunk of memory. You shouldn't be able    */
 /* to do anything to it except create it and manipulate it via          */
 /* EST_ChunkPtr. The private operator::new takes a placement argument   */
 /* which is actually the number of bytes of memory in the body of the   */
 /* chunk.                                                               */
 /*                                                                      */
 /* If the use counter overflows, it sticks. Anything with more than     */
 /* SHRT_MAX references to it is probably permanent.                     */
 /*                                                                      */
 /************************************************************************/

class EST_ChunkPtr;

class EST_Chunk  {
  public:
    typedef  unsigned short use_counter;
#       define MAX_CHUNK_COUNT (USHRT_MAX)
    typedef  int EST_chunk_size;
#       define MAX_CHUNK_SIZE  (INT_MAX)

  private:
    use_counter count;
    EST_chunk_size size;
    int malloc_flag; // set if this was got from malloc (rather than new)
    char  memory[1];

    EST_Chunk(void);
    ~EST_Chunk();

    EST_Chunk *operator & ();
    void *operator new (size_t size, int bytes);
    void operator delete (void *it);
    
    void operator ++ ()
        CII({if (count < MAX_CHUNK_COUNT) ++count; });

    void operator -- ()
        CII({if (count < MAX_CHUNK_COUNT) if (--count == 0) delete this;});

  public:
    friend class EST_ChunkPtr;

    friend EST_ChunkPtr chunk_allocate(int bytes);
    friend EST_ChunkPtr chunk_allocate(int bytes, const char *initial, int initial_len);
    friend EST_ChunkPtr chunk_allocate(int bytes, const EST_ChunkPtr &initial, int initial_start, int initial_len);

    friend void cp_make_updatable(EST_ChunkPtr &shared, EST_chunk_size inuse);
    friend void cp_make_updatable(EST_ChunkPtr &shared);

    friend void grow_chunk(EST_ChunkPtr &shared, EST_chunk_size inuse, EST_chunk_size newsize);
    friend void grow_chunk(EST_ChunkPtr &shared, EST_chunk_size newsize);

    friend ostream &operator << (ostream &s, const EST_Chunk &chp);
    friend void tester(void);
};

 /************************************************************************/
 /*                                                                      */
 /* Pointers to chunks. Initialising them and assigning them around      */
 /* keeps track of use counts. We allow them to be cast to char * as a   */
 /* way of letting people work on them with standard functions,          */
 /* however it is bad voodoo to hold on to such a cast chunk for more    */
 /* than a trivial amount of time.                                       */
 /*                                                                      */
 /************************************************************************/

class EST_ChunkPtr {
  private:
    EST_Chunk *ptr;

    EST_ChunkPtr(EST_Chunk *chp) CII({
      if ((ptr=chp))
	++ *ptr;
    });
  public:
    EST_ChunkPtr(void) { ptr = (EST_Chunk *)NULL; };
    
    EST_ChunkPtr(const EST_ChunkPtr &cp) CII({
      ptr=cp.ptr;
      if (ptr)
	++ *ptr;
    });

    ~EST_ChunkPtr(void) CII({ if (ptr) -- *ptr; });

    int size(void) const { return ptr?ptr->size:0; };
    int shareing(void) const { return ptr?(ptr->count >1):0; };
    int count(void) const { return ptr?(ptr->count):-1; };

    EST_ChunkPtr &operator = (EST_ChunkPtr cp) CII({
      // doing it in this order means self assignment is safe.
      if (cp.ptr)
	++ *(cp.ptr);
      if (ptr)
	-- *ptr;
      ptr=cp.ptr;
      return *this;
    });

    // If they manage to get hold of one...
    // Actually usually used to assign NULL and so (possibly) deallocate
    // the chunk currently pointed to.
    EST_ChunkPtr &operator = (EST_Chunk *chp) CII({
      // doing it in this order means self assignment is safe.
      if (chp)
	++ *chp;
      if (ptr)
	-- *ptr;
      ptr=chp;
      return *this;
    });
 
    // Casting to a non-const pointer causes a
    // warning to stderr if the chunk is shared.
    operator char*() CII({
      if (ptr && ptr->count > 1) 
	{ 
	  CHUNK_WARN("getting writable version of shared chunk\n");
	  cp_make_updatable(*this);
	}
      return ptr?&(ptr->memory[0]):(char *)NULL;
    });
    operator const char*() const CII({
      return ptr?&(ptr->memory[0]):(const char *)NULL;
    });
    operator const char*() CII({
      return ptr?&(ptr->memory[0]):(const char *)NULL;
    });


    const char operator [] (int i) const { return ptr->memory[i]; };
    char &operator () (int i) CII({ 
      if (ptr->count>1) 
	{
	  CHUNK_WARN("getting writable version of shared chunk\n");
	  cp_make_updatable(*this); 
	}
      return ptr->memory[i]; 
    });

    // Creating a new one
    friend EST_ChunkPtr chunk_allocate(int size);
    friend EST_ChunkPtr chunk_allocate(int bytes, const char *initial, int initial_len);
    friend EST_ChunkPtr chunk_allocate(int bytes, const EST_ChunkPtr &initial, int initial_start, int initial_len);

    // Make sure the memory isn`t shared.
    friend void cp_make_updatable(EST_ChunkPtr &shared, EST_Chunk::EST_chunk_size inuse);
    friend void cp_make_updatable(EST_ChunkPtr &shared);

    // Make sure there is enough room (also makes updatable)
    friend void grow_chunk(EST_ChunkPtr &shared, EST_Chunk::EST_chunk_size inuse, EST_Chunk::EST_chunk_size newsize);
    friend void grow_chunk(EST_ChunkPtr &shared, EST_Chunk::EST_chunk_size newsize);

    // we print it by just printing the chunk
    friend ostream &operator << (ostream &s, const EST_ChunkPtr &cp) { return (s<< *cp.ptr); };

    friend void tester(void);
};

#endif