include/borderbasix/memory.cc File Reference

Go to the source code of this file.

Functions


Function Documentation

void CLEAR_ELEM ( void *  ptr,
int  size 
) [inline]

Definition at line 26 of file memory.cc.

00027 {
00028   for(unsigned int i=0;i<size/(sizeof(T));i++)
00029     ((T*)ptr+i)->~T();
00030 }

void freeplacemon (  ) 

Definition at line 697 of file placemon.cc.

00698 {
00699   MAC_REV_FREE<mon>(int2mon_,sizeplace*sizeof(mon));
00700   MAC_REV_FREE<mon>(mon2intmon,sizeplace*sizeof(mon));
00701   free(mon2intint);
00702   sizeplace=0;
00703 
00704 }

void INIT_ELEM ( void *  ptr,
int  size 
) [inline]

Definition at line 5 of file memory.cc.

00006 {
00007   //cout<<"je passe par l'init"<<endl;
00008   for(unsigned i=0;i<(size/(sizeof(T)));i++)
00009     new((T*)ptr+i) T;
00010 
00011 }

void MAC_REV_FREE ( void *  ptr,
int  size 
) [inline]

Definition at line 65 of file memory.cc.

00066 {
00067   if(size>0)
00068     CLEAR_ELEM<T>(ptr,size);
00069   free(ptr);
00070 }

void* MAC_REV_MALLOC ( int  size  )  [inline]

Definition at line 39 of file memory.cc.

Referenced by Dump().

00040 {
00041   //cout<<"c'est celui la "<<endl;
00042   void * res;
00043   res=malloc(size);
00044   INIT_ELEM<T>(res,size);
00045   return res;
00046 }

void* MAC_REV_REALLOC ( void *  ptr,
int  size,
int  newsize 
) [inline]

Definition at line 49 of file memory.cc.

Referenced by freeint2mon(), and putmon2().

00050 {
00051   void *res=ptr;
00052   if(size<newsize)
00053     {
00054       res=realloc(ptr,newsize);
00055       INIT_ELEM<T>((char*)res+size,newsize-size);
00056     }
00057   if(size>newsize)
00058     {
00059       CLEAR_ELEM<T>((char*)ptr+newsize,size-newsize);
00060       res=realloc(ptr,newsize);
00061     }
00062   return res;
00063 }

void sweep ( typdump &  dump,
Base b 
) [inline]

Definition at line 164 of file memory.cc.

References Base< predicat >::begin(), and Base< predicat >::end().

Referenced by main().

00169 {
00170   typedef typename typdump::value_type::pol_t::coeff_t coeff;
00171   typedef typename Base::mon mon;
00172   for(typename typdump::iterator iter=dump.begin()
00173         ;iter!=dump.end();iter++)
00174     {
00175       for(int i=0;i<(iter->size);i++) {
00176         MAC_REV_FREE<coeff>(iter->nf[i].nf,iter->nf[i].size*sizeof(coeff));
00177 #ifdef sparse
00178         MAC_REV_FREE<int>(iter->nf[i].nfind,iter->nf[i].size*sizeof(int));
00179 #endif      
00180       }
00181       MAC_REV_FREE<pol<mon,coeff> >(iter->nf,iter->size*sizeof(pol<mon,coeff>));
00182     }
00183   for(typename Base::iterator iter=b.begin()
00184         ;iter!=b.end();iter++)
00185     {
00186       MAC_REV_FREE<mon>(iter->accept,iter->taille1*sizeof(mon));
00187       MAC_REV_FREE<mon>(iter->refuse,iter->taille2*sizeof(mon));
00188     } 
00189   //freeplacemon();
00190   
00191 }


Generated on 6 Dec 2012 for borderbasix by  doxygen 1.6.1