This file is indexed.

/usr/include/openturns/Memory.hxx is in libopenturns-dev 1.5-7build2.

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
//                                               -*- C++ -*-
/**
 *  @file  Memory.hxx
 *  @brief This file declares memory debugging functions
 *
 *  Copyright 2005-2015 Airbus-EDF-IMACS-Phimeca
 *
 *  This library is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This library 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 Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 *  @author dutka
 *  @date   2008-05-21 17:44:02 +0200 (Wed, 21 May 2008)
 */
#ifndef OPENTURNS_MEMORY_HXX
#define OPENTURNS_MEMORY_HXX

#include <cstddef>

#include "OTdebug.h"

#ifdef DEBUG_MEMORY

#include <new>
#include <map>
#include <cstdlib>

#include "OTthread.hxx"
#include "OTmemory.hxx"

#ifndef SWIG

template <typename T>
struct CStyleAllocator
{
  typedef T         value_type;
  typedef T*        pointer;
  typedef const T*  const_pointer;
  typedef T&        reference;
  typedef const T&  const_reference;
  typedef ptrdiff_t difference_type;
  typedef size_t    size_type;

  template <typename U>
  struct rebind
  {
    typedef CStyleAllocator<U> other;
  };

  CStyleAllocator() {}

  CStyleAllocator(const CStyleAllocator & other) {}

  template <typename U> CStyleAllocator(const CStyleAllocator<U> & other) {}

  ~CStyleAllocator() {}

  pointer allocate(size_type n, const void * = 0)
  {
    if (n > this->max_size()) std::__throw_bad_alloc();
    return static_cast<T*>( std::calloc( n, sizeof(T) ) );
  }

  void deallocate(pointer p, size_type)
  {
    std::free( p );
  }

  size_type max_size() const
  {
    return size_t(-1) / sizeof(T);
  }

  void construct(void * p, const T & x)
  {
    ::new((void *)p) T(x);
  }

  void destroy(pointer p)
  {
    p->~T();
  }

  pointer address(reference x) const
  {
    return &x;
  }

  const_pointer address(const_reference x) const
  {
    return &x;
  }
};

template <typename T>
bool operator == (const CStyleAllocator<T> & lhs, const CStyleAllocator<T> & rhs)
{
  return true;
}

template <typename T>
bool operator != (const CStyleAllocator<T> & lhs, const CStyleAllocator<T> & rhs)
{
  return false;
}

struct OT_API _OpenTURNS_memory
{
  void * ptr_;
  size_t size_;
};

typedef std::map < void *,
        _OpenTURNS_memory *,
        std::less<void*>,
        CStyleAllocator<std::pair<void *, _OpenTURNS_memory *> > > MemContainer;

typedef std::map<size_t, size_t, std::less<size_t>,  CStyleAllocator<std::pair<size_t, size_t> > > MemSpectrum;

class OT_API MemoryImplementation
{
public:
  MemContainer memList_;
  MemSpectrum memSpectrum_;
  size_t memoryUsage_;
  size_t fullMemoryUsage_;
  size_t maxMemoryUsage_;
  size_t maxFullMemoryUsage_;
  bool flag_;

  MemoryImplementation();
  ~MemoryImplementation();
};

class OT_API Memory
{
  static MemoryImplementation * p_impl_;
  Memory() {}
  static void Release();
public:
  ~Memory() {}
  static MemoryImplementation & GetInstance();
};

class OT_API LockNewDelete
{
  static pthread_mutex_t NewMutex_;
  static void Lock();
  static void Unlock();
public:
  LockNewDelete();
  ~LockNewDelete();
};

#endif /* SWIG */

#endif /* DEBUG_MEMORY */

OT_API size_t GetMemoryUsage();
OT_API size_t GetFullMemoryUsage();
OT_API size_t GetMaxMemoryUsage();
OT_API size_t GetMaxFullMemoryUsage();

OT_API void printMemoryUsage();
OT_API void printMemorySpectrum();

OT_API void SetMemoryFlag(bool);

#endif /* OPENTURNS_MEMORY_HXX */