/usr/include/sc/util/container/carray.h is in libsc-dev 2.3.1-16build1.
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 | //
// carray.h --- C Style Arrays
//
#ifndef _util_container_carray_h
#define _util_container_carray_h
namespace sc {
template <class T>
T **
new_c_array2(int l, int m, T)
{
T *a = 0;
T **b = 0;
if (l*m) a = new T[l*m];
if (l) b = new T*[l];
for (int i=0; i<l; i++) b[i] = &a[i*m];
return b;
}
template <class T>
T **
new_zero_c_array2(int l, int m, T)
{
T *a = 0;
T **b = 0;
if (l*m) a = new T[l*m];
if (l) b = new T*[l];
for (int i=0; i<l; i++) {
b[i] = &a[i*m];
for (int j=0; j<m; j++) {
b[i][j] = 0;
}
}
return b;
}
template <class T>
void
delete_c_array2(T**b)
{
if (b) delete[] b[0];
delete[] b;
}
template <class T>
T ***
new_c_array3(int l, int m, int n, T)
{
T *a = 0;
T **b = 0;
T ***c = 0;
if (l*m*n) a = new T[l*m*n];
if (l*m) b = new T*[l*m];
if (l) c = new T**[l];
for (int i=0,ij=0; i<l; i++) {
c[i] = &b[i*m];
for (int j=0; j<m; j++,ij++) {
c[i][j] = &a[ij*n];
}
}
return c;
}
template <class T>
T ***
new_zero_c_array3(int l, int m, int n, T)
{
T *a = 0;
T **b = 0;
T ***c = 0;
if (l*m*n) a = new T[l*m*n];
if (l*m) b = new T*[l*m];
if (l) c = new T**[l];
for (int i=0,ij=0; i<l; i++) {
c[i] = &b[i*m];
for (int j=0; j<m; j++,ij++) {
c[i][j] = &a[ij*n];
for (int k=0; k<n; k++) {
c[i][j][k] = 0;
}
}
}
return c;
}
template <class T>
void
delete_c_array3(T***b)
{
if (b && b[0]) delete[] b[0][0];
if (b) delete[] b[0];
delete[] b;
}
}
#endif
// ///////////////////////////////////////////////////////////////////////////
// Local Variables:
// mode: c++
// c-file-style: "CLJ"
// End:
|