@@ -33,19 +33,19 @@ namespace MERGESAT_NSPACE
3333template <class T > class RegionAllocator
3434{
3535 T *memory;
36- uint32_t sz;
37- uint32_t cap;
38- uint32_t wasted_;
36+ uint64_t sz;
37+ uint64_t cap;
38+ uint64_t wasted_;
3939
40- void capacity (uint32_t min_cap);
40+ void capacity (uint64_t min_cap);
4141
4242 public:
4343 // TODO: make this a class for better type-checking?
44- typedef uint32_t Ref;
45- enum { Ref_Undef = UINT32_MAX };
44+ typedef uint64_t Ref;
45+ enum { Ref_Undef = UINT64_MAX };
4646 enum { Unit_Size = sizeof (uint32_t ) };
4747
48- explicit RegionAllocator (uint32_t start_cap = 1024 * 1024 ) : memory(NULL ), sz(0 ), cap(0 ), wasted_(0 )
48+ explicit RegionAllocator (uint64_t start_cap = 1024 * 1024 ) : memory(NULL ), sz(0 ), cap(0 ), wasted_(0 )
4949 {
5050 capacity (start_cap);
5151 }
@@ -55,8 +55,8 @@ template <class T> class RegionAllocator
5555 }
5656
5757
58- uint32_t size () const { return sz; }
59- uint32_t wasted () const { return wasted_; }
58+ uint64_t size () const { return sz; }
59+ uint64_t wasted () const { return wasted_; }
6060
6161 Ref alloc (int size);
6262 void free (int size) { wasted_ += size; }
@@ -102,17 +102,17 @@ template <class T> class RegionAllocator
102102 }
103103};
104104
105- template <class T > void RegionAllocator<T>::capacity(uint32_t min_cap)
105+ template <class T > void RegionAllocator<T>::capacity(uint64_t min_cap)
106106{
107107 if (cap >= min_cap) return ;
108108
109- uint32_t prev_cap = cap;
109+ uint64_t prev_cap = cap;
110110 while (cap < min_cap) {
111111 // NOTE: Multiply by a factor (13/8) without causing overflow, then add 2 and make the
112112 // result even by clearing the least significant bit. The resulting sequence of capacities
113- // is carefully chosen to hit a maximum capacity that is close to the '2^32 -1' limit when
114- // using 'uint32_t ' as indices so that as much as possible of this space can be used.
115- uint32_t delta = ((cap >> 1 ) + (cap >> 3 ) + 2 ) & ~1 ;
113+ // is carefully chosen to hit a maximum capacity that is close to the '2^64 -1' limit when
114+ // using 'uint64_t ' as indices so that as much as possible of this space can be used.
115+ uint64_t delta = ((cap >> 1 ) + (cap >> 3 ) + 2 ) & ~1 ;
116116 cap += delta;
117117
118118 if (cap <= prev_cap) throw OutOfMemoryException ();
@@ -130,7 +130,7 @@ template <class T> typename RegionAllocator<T>::Ref RegionAllocator<T>::alloc(in
130130 assert (size > 0 );
131131 capacity (sz + size);
132132
133- uint32_t prev_sz = sz;
133+ uint64_t prev_sz = sz;
134134 sz += size;
135135
136136 // Handle overflow:
0 commit comments