From: Marek P. <ma...@us...> - 2001-11-21 22:32:14
|
Update of /cvsroot/javaprofiler/library/src/allocator In directory usw-pr-cvs1:/tmp/cvs-serv12170/src/allocator Modified Files: Makefile.rules allocator.cpp allocator.h dir.info Log Message: some parts completely rewritten; changes in communication interface to make it faster; ported to linux Index: Makefile.rules =================================================================== RCS file: /cvsroot/javaprofiler/library/src/allocator/Makefile.rules,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** Makefile.rules 2001/07/22 23:37:58 1.2 --- Makefile.rules 2001/11/21 22:31:41 1.3 *************** *** 1,3 **** allocator.o \ ! allocator.obj: allocator.cpp ../main/includes.h $(CCC) $(CPPFLAGS) allocator.cpp --- 1,3 ---- allocator.o \ ! allocator.obj: allocator.cpp $(CCC) $(CPPFLAGS) allocator.cpp Index: allocator.cpp =================================================================== RCS file: /cvsroot/javaprofiler/library/src/allocator/allocator.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** allocator.cpp 2001/09/18 22:19:28 1.6 --- allocator.cpp 2001/11/21 22:31:42 1.7 *************** *** 33,38 **** */ ! #include "../main/includes.h" void Allocator::allocNewBlock() { --- 33,59 ---- */ ! #ifdef USE_ALLOCATOR + #include "../allocator/allocator.h" + #include "../prof/prof.h" + + void* Allocator::get( size_t unitSize) { + + if( !_unitSize) _unitSize = unitSize; + + if( !_freeUnits) allocNewBlock(); + + void* unit = _freeUnits; + _freeUnits = *(void**)_freeUnits; + + return unit; + } + + void Allocator::put( void* unit) { + + *(void**)unit = _freeUnits; + _freeUnits = unit; + } + void Allocator::allocNewBlock() { *************** *** 55,60 **** Allocator::~Allocator() { - Prof::destroy(); - size_t len = _unitSize*NUM_UNITS_IN_BLOCK+sizeof( void*); --- 76,79 ---- *************** *** 66,67 **** --- 85,89 ---- } } + + #endif + Index: allocator.h =================================================================== RCS file: /cvsroot/javaprofiler/library/src/allocator/allocator.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** allocator.h 2001/09/02 20:14:21 1.8 --- allocator.h 2001/11/21 22:31:42 1.9 *************** *** 36,39 **** --- 36,43 ---- #define _ALLOCATOR_H_ + #ifdef USE_ALLOCATOR + + #include "../main/includes.h" + /** Allocator. ** This class serves for allocation of memory units of *************** *** 69,75 **** public: ! /** Constructor ** ! ** @param unitSize size of memory unit */ Allocator( size_t unitSize = 0) : --- 73,79 ---- public: ! /** Constructor. ** ! ** @param unitSize size of memory unit */ Allocator( size_t unitSize = 0) : *************** *** 79,83 **** _unitSize( unitSize) ! {}; /// Destructor --- 83,87 ---- _unitSize( unitSize) ! {} /// Destructor *************** *** 86,117 **** /** Gets memory unit. ** If the 'unitSize' argument is supplied and ! ** the size of memory unit hasn't been allready ** initialized, it is initialized to 'unitSize'. ** ! ** @param unitSize size of memory unit ** ** @return pointer to memory unit */ - - void* get( size_t unitSize = 0) { ! if( !_unitSize) _unitSize = unitSize; - if( !_freeUnits) allocNewBlock(); - - void* unit = _freeUnits; - _freeUnits = *(void**)_freeUnits; - - return unit; - } - /** Puts memory unit previously obtained by get() method back. ** ** @param unit pointer to memory unit */ - - void put( void* unit) { ! *(void**)unit = _freeUnits; ! _freeUnits = unit; ! } private: --- 90,107 ---- /** Gets memory unit. ** If the 'unitSize' argument is supplied and ! ** the size of memory unit hasn't been already ** initialized, it is initialized to 'unitSize'. ** ! ** @param unitSize size of memory unit ** ** @return pointer to memory unit */ ! void* get( size_t unitSize = 0); /** Puts memory unit previously obtained by get() method back. ** ** @param unit pointer to memory unit */ ! void put( void* unit); private: *************** *** 122,124 **** --- 112,115 ---- }; + #endif #endif // _ALLOCATOR_H_ Index: dir.info =================================================================== RCS file: /cvsroot/javaprofiler/library/src/allocator/dir.info,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** dir.info 2001/07/22 23:37:58 1.2 --- dir.info 2001/11/21 22:31:42 1.3 *************** *** 1,3 **** FILES = allocator - CLEAN_FILES = *.pdb *.obj *.o --- 1,2 ---- |