This file is indexed.

/usr/include/ITK-4.5/vnl/vnl_alloc.h is in libinsighttoolkit4-dev 4.5.0-3.

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
// This is core/vnl/vnl_alloc.h
#ifndef vnl_alloc_h_
#define vnl_alloc_h_
#ifdef VCL_NEEDS_PRAGMA_INTERFACE
#pragma interface
#endif
//:
// \file
// \author unknown
//
// \brief Default node allocator.
//
// With a reasonable compiler, this should be roughly as fast as the
// original STL class-specific allocators, but with less fragmentation.
// Default_alloc_template parameters are experimental and MAY
// DISAPPEAR in the future.  Clients should just use vcl_alloc for now.
//
// Important implementation properties:
// -  If the client request an object of size > __MAX_BYTES, the resulting
//    object will be obtained directly from malloc.
// -  In all other cases, we allocate an object of size exactly
//    ROUND_UP(requested_size).  Thus the client has enough size
//    information that we can return the object to the proper free li*st
//    without permanently losing part of the object.
//
// The first template parameter specifies whether more than one thread
// may use this allocator.  It is safe to allocate an object from
// one instance of a default_alloc and deallocate it with another
// one.  This effectively transfers its ownership to the second one.
// This may have undesirable effects on reference locality.
// The second parameter is unreferenced and serves only to allow the
// creation of multiple default_alloc instances.
//
// Note that containers built on different allocator instances have
// different types, limiting the utility of this approach.

#include <vcl_cstddef.h> // size_t lives here

const int VNL_ALLOC_ALIGN = 8;
const vcl_size_t VNL_ALLOC_MAX_BYTES = 256;
const vcl_size_t VNL_ALLOC_NFREELISTS = VNL_ALLOC_MAX_BYTES/VNL_ALLOC_ALIGN;

class vnl_alloc
{
  static vcl_size_t ROUND_UP(vcl_size_t bytes) {
    return (bytes + VNL_ALLOC_ALIGN-1) & ~(VNL_ALLOC_ALIGN - 1);
  }
  union obj;
  friend union obj;
  union obj {
    union obj * free_list_link;
    char client_data[1];    /* The client sees this.        */
  };
# if defined ( __SUNPRO_CC ) || defined ( _AIX )
  static obj * free_list[];
  // Specifying a size results in duplicate def for 4.1
# else
  static obj * free_list[VNL_ALLOC_NFREELISTS];
# endif
  static  vcl_size_t FREELIST_INDEX(vcl_size_t bytes) {
    return (bytes + VNL_ALLOC_ALIGN-1)/VNL_ALLOC_ALIGN - 1;
  }

  // Returns an object of size n, and optionally adds to size n free li*st.
  static void *refill(vcl_size_t n);
  // Allocates a chunk for nobjs of size size.  nobjs may be reduced
  // if it is inconvenient to allocate the requested number.
  static char *chunk_alloc(vcl_size_t size, int &nobjs);

  // Chunk allocation state.
  static char *start_free;
  static char *end_free;
  static vcl_size_t heap_size;

  class lock
  {
   public:
    lock() {}
    ~lock() {}
  };
  friend class lock;

 public:
  // this one is needed for proper vcl_simple_alloc wrapping
  typedef char value_type;

  /* n must be > 0      */
  static void * allocate(vcl_size_t n) {
    obj * * my_free_list;
    obj *  result;

    if (n > VNL_ALLOC_MAX_BYTES) {
      return (void*)new char[n];
    }
    my_free_list = free_list + FREELIST_INDEX(n);
    // Acquire the lock here with a constructor call.
    // This ensures that it is released in exit or during stack
    // unwinding.
    result = *my_free_list;
    if (result == 0) {
      void *r = refill(ROUND_UP(n));
      return r;
    }
    *my_free_list = result -> free_list_link;
    return result;
  };

  /* p may not be 0 */
  static void deallocate(void *p, vcl_size_t n)
  {
    obj *q = (obj *)p;
    obj *  * my_free_list;

    if (n > VNL_ALLOC_MAX_BYTES) {
      delete [] (char*)p;
      return;
    }
    my_free_list = free_list + FREELIST_INDEX(n);
    q -> free_list_link = *my_free_list;
    *my_free_list = q;
  }

  static void * reallocate(void *p, vcl_size_t old_sz, vcl_size_t new_sz);
};

# endif // vnl_alloc_h_