34 #if defined(__CHECK_MEMORY__)
39 void adpool::sanity_check(
void)
47 cerr <<
"Error in adpool structure" <<
endl;
50 cout <<
"Depth = " << depth <<
endl;
57 void adpool::sanity_check2(
void)
65 cerr <<
"Error in adpool adresses" <<
endl;
68 cout <<
"Depth = " << depth <<
endl;
75 void adpool::sanity_check(
void * ptr)
84 cerr <<
"both allocated and unallocated memory at entry "
97 void adpool::write_pointers(
int mmin,
int mmax)
104 if (index >=mmin && index <=mmax)
105 cout << index <<
" " << int(p) <<
endl;
122 #if defined(__CHECK_MEMORY__)
125 cerr <<
"Error in adpool structure" <<
endl;
132 cerr <<
"Error in adpool structure" <<
endl;
141 #if defined(__CHECK_MEMORY__)
144 cout <<
"trying to allocate already allocated object " <<
endl;
149 assert(
nvar <= SHRT_MAX);
153 #if defined (INCLUDE_BLOCKSIZE)
160 #if defined(__CHECK_MEMORY__)
164 int adpool::bad(link * p)
170 for (
int i=1;i<maxchunks;i++)
172 if ( p >= minaddress[i] && p <= maxaddress[i])
185 cerr <<
"bad pool object" <<
endl;
194 int adpool::badaddress(link * p)
198 for (
int i=0;i<=nalloc;i++)
200 if ( ip == pvalues[i])
217 #if defined(SAFE_ALL)
221 cerr <<
"trying to add wrong sized memory block to adpool" <<
endl;
226 #if defined (INCLUDE_BLOCKSIZE)
230 if (tmp->blocksize !=
size)
232 cerr <<
"trying to add wrong sized memory block to adpool" <<
endl;
238 #if defined(__CHECK_MEMORY__)
243 cout <<
"trying to deallocate allocated object " <<
endl;
278 size_t i2=2*
sizeof(double);
281 cout <<
"Error because sizeof(twointsandptr)>2*sizeof(double)" <<
endl;
289 #if defined(__CHECK_MEMORY__)
308 cerr <<
"You can not change the allocation size in mid stream\n"
309 <<
" current size is " <<
size <<
" trying to change to "
321 #if defined(__CHECK_MEMORY__)
336 #if defined(__CHECK_MEMORY__)
355 #if defined(__CHECK_MEMORY__)
356 const int pvalues_size=500000;
361 pvalues=
new int[pvalues_size];
365 const size_t overhead =
sizeof(intptr_t);
366 const size_t chunk_size = 16 * 65000 - overhead;
373 cerr <<
"error in adpool object "
374 <<
" you must set the unit size " <<
endl;
377 const size_t total_size = overhead +
nelem *
size;
378 char* real_start =
new char[total_size];
379 memset(real_start, 0, total_size);
381 #if defined(_USE_VALGRIND_)
382 VALGRIND_MAKE_MEM_NOACCESS(realstart,chunk_size);
385 char* start = real_start + overhead;
386 char* last = &start[(
nelem - 1) * size];
389 #if defined(__CHECK_MEMORY__)
390 if (num_chunks<maxchunks)
393 maxaddress[
num_chunks]=(real_start+chunk_size-1);
400 *(
char**)real_start = 0;
408 #if defined(__CHECK_MEMORY__)
409 if (nalloc>pvalues_size-1)
411 cerr <<
"Error in check memory need to make pvalues bigger than "
412 << pvalues_size <<
endl;
415 pvalues[nalloc++]=int(start);
418 for (
char* p = start; p < last; p +=
size)
420 ((
link *)p)->next = (
link*)(p+size);
421 #if defined(__CHECK_MEMORY__)
422 pvalues[nalloc++]=int((
link*)(p+size));
426 ((
link*)last)->next = 0;
428 first = (
double*)start;
439 cerr <<
"error in adpool object "
440 <<
" you must set the unit size " <<
endl;
445 for (
size_t i=1;i<=
nelem;i++)
448 for(
unsigned int j=1;j<=
size/
sizeof(double)-2;j++) *ptr++=0.0;
void clean(void)
Description not yet available.
void deallocate(void)
Description not yet available.
void set_size(const size_t)
Set size of adpool.
Description not yet available.
int depth_check(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
prnstream & endl(prnstream &)
void * alloc(void)
Allocate memory for link*.
void free(void *b)
Description not yet available.
adpool()
Default constructor.
Description not yet available.
Description not yet available.
Description not yet available.