42 #ifdef GECODE_PEAKHEAP_MALLOC_H 46 #ifdef GECODE_PEAKHEAP_MALLOC_MALLOC_H 47 #include <malloc/malloc.h> 79 T*
alloc(
long unsigned int n);
111 void free(T*
b,
long unsigned int n);
119 void free(T*
b,
long int n);
127 void free(T*
b,
unsigned int n);
148 T*
realloc(T*
b,
long unsigned int n,
long unsigned int m);
161 T*
realloc(T*
b,
long int n,
long int m);
174 T*
realloc(T*
b,
unsigned int n,
unsigned int m);
196 T**
realloc(T**
b,
long unsigned int n,
long unsigned int m);
205 T**
realloc(T**
b,
long int n,
long int m);
214 T**
realloc(T**
b,
unsigned int n,
unsigned int m);
233 static T*
copy(T*
d,
const T* s,
long unsigned int n);
243 static T*
copy(T*
d,
const T* s,
long int n);
253 static T*
copy(T*
d,
const T* s,
unsigned int n);
263 static T*
copy(T*
d,
const T* s,
int n);
272 static T**
copy(T**
d,
const T** s,
long unsigned int n);
281 static T**
copy(T**
d,
const T** s,
long int n);
290 static T**
copy(T**
d,
const T** s,
unsigned int n);
299 static T**
copy(T**
d,
const T** s,
int n);
308 void rfree(
void*
p,
size_t s);
314 static void*
operator new(
size_t s)
throw() { (void) s;
return NULL; }
316 static void operator delete(
void*
p) { (void)
p; };
320 const Heap& operator =(
const Heap&) {
return *
this; }
321 #ifdef GECODE_PEAKHEAP 348 static void*
operator new(
size_t s);
351 static void operator delete(
void*
p);
363 #ifdef GECODE_PEAKHEAP 365 _cur += GECODE_MSIZE(
p);
376 #ifdef GECODE_PEAKHEAP 378 _cur -= GECODE_MSIZE(
p);
386 #ifdef GECODE_PEAKHEAP 388 _cur -= GECODE_MSIZE(
p);
396 #ifdef GECODE_PEAKHEAP 398 _cur -= GECODE_MSIZE(
p);
402 #ifdef GECODE_PEAKHEAP 404 _cur += GECODE_MSIZE(
p);
408 if (
p != NULL || s == 0)
419 HeapAllocated::operator
new(
size_t s) {
423 HeapAllocated::operator
delete(
void*
p) {
436 T*
p = static_cast<T*>(
ralloc(
sizeof(T)*
n));
437 for (
long unsigned int i=
n;
i--; )
438 (
void)
new (
p+
i) T();
445 return alloc<T>(static_cast<long unsigned int>(
n));
450 return alloc<T>(static_cast<long unsigned int>(
n));
456 return alloc<T>(static_cast<long unsigned int>(
n));
462 for (
long unsigned int i=
n;
i--; )
470 free<T>(
b, static_cast<long unsigned int>(
n));
475 free<T>(
b, static_cast<long unsigned int>(
n));
481 free<T>(
b, static_cast<long unsigned int>(
n));
489 T*
p = static_cast<T*>(
ralloc(
sizeof(T)*m));
491 (
void)
new (
p+
i) T(
b[
i]);
492 for (
long unsigned int i=
n;
i<m;
i++)
493 (
void)
new (
p+
i) T();
500 assert((
n >= 0) && (m >= 0));
501 return realloc<T>(
b,static_cast<long unsigned int>(
n),
502 static_cast<long unsigned int>(m));
507 return realloc<T>(
b,static_cast<long unsigned int>(
n),
508 static_cast<long unsigned int>(m));
513 assert((
n >= 0) && (m >= 0));
514 return realloc<T>(
b,static_cast<long unsigned int>(
n),
515 static_cast<long unsigned int>(m));
518 #define GECODE_SUPPORT_REALLOC(T) \ 521 Heap::realloc<T>(T* b, long unsigned int, long unsigned int m) { \ 522 return static_cast<T*>(rrealloc(b,m*sizeof(T))); \ 526 Heap::realloc<T>(T* b, long int n, long int m) { \ 527 assert((n >= 0) && (m >= 0)); \ 528 return realloc<T>(b,static_cast<long unsigned int>(n), \ 529 static_cast<long unsigned int>(m)); \ 533 Heap::realloc<T>(T* b, unsigned int n, unsigned int m) { \ 534 return realloc<T>(b,static_cast<long unsigned int>(n), \ 535 static_cast<long unsigned int>(m)); \ 539 Heap::realloc<T>(T* b, int n, int m) { \ 540 assert((n >= 0) && (m >= 0)); \ 541 return realloc<T>(b,static_cast<long unsigned int>(n), \ 542 static_cast<long unsigned int>(m)); \ 557 #undef GECODE_SUPPORT_REALLOC 562 return static_cast<T**>(
rrealloc(
b,m*
sizeof(T*)));
567 assert((
n >= 0) && (m >= 0));
568 return realloc<T*>(
b,static_cast<long unsigned int>(
n),
569 static_cast<long unsigned int>(m));
574 return realloc<T*>(
b,static_cast<long unsigned int>(
n),
575 static_cast<long unsigned int>(m));
580 assert((
n >= 0) && (m >= 0));
581 return realloc<T*>(
b,static_cast<long unsigned int>(
n),
582 static_cast<long unsigned int>(m));
588 for (
long unsigned int i=
n;
i--; )
596 return copy<T>(
d,s,static_cast<long unsigned int>(
n));
601 return copy<T>(
d,s,static_cast<long unsigned int>(
n));
607 return copy<T>(
d,s,static_cast<long unsigned int>(
n));
610 #define GECODE_SUPPORT_COPY(T) \ 613 Heap::copy(T* d, const T* s, long unsigned int n) { \ 614 return static_cast<T*>(Support::allocator.memcpy(d,s,n*sizeof(T))); \ 618 Heap::copy(T* d, const T* s, long int n) { \ 620 return copy<T>(d,s,static_cast<long unsigned int>(n)); \ 624 Heap::copy(T* d, const T* s, unsigned int n) { \ 625 return copy<T>(d,s,static_cast<long unsigned int>(n)); \ 629 Heap::copy(T* d, const T* s, int n) { \ 631 return copy<T>(d,s,static_cast<long unsigned int>(n)); \ 646 #undef GECODE_SUPPORT_COPY 657 return copy<T*>(
d,s,static_cast<long unsigned int>(
n));
662 return copy<T*>(
d,s,static_cast<long unsigned int>(
n));
668 return copy<T*>(
d,s,static_cast<long unsigned int>(
n));
671 #ifdef GECODE_PEAKHEAP static T * copy(T *d, const T *s, long unsigned int n)
Copy n objects starting at s to d.
void * realloc(void *p, size_t n)
Return address of reallocated memory block p of size n.
#define GECODE_SUPPORT_REALLOC(T)
const FloatNum max
Largest allowed float value.
void rfree(void *p)
Free memory block starting at p.
void * ralloc(size_t s)
Allocate s bytes from heap.
Exception: Memory exhausted
Heap(void)
Default constructor (ensuring that only a single instance is created)
A mutex for mutual exclausion among several threads.
int p
Number of positive literals for node type.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from heap.
const FloatNum min
Smallest allowed float value.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
struct Gecode::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
#define GECODE_SUPPORT_EXPORT
Heap memory management class
Allocator allocator
The single global default memory allocator.
#define GECODE_SUPPORT_COPY(T)
void * rrealloc(void *p, size_t s)
Change memory block starting at p to size s.
void free(T *b, long unsigned int n)
Delete n objects starting at b.
Heap heap
The single global heap.
T * realloc(T *b, long unsigned int n, long unsigned int m)
Reallocate block of n objects starting at b to m objects of type T from heap.
Gecode toplevel namespace
void * alloc(size_t n)
Allocate memory block of size n.
Base class for heap allocated objects.
void free(void *p)
Free memory block p.