12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- /***********************************************************************/
- //文 件 名:CBuffers.h
- //功 能:CBuffers类声明
- // CBuffers类是一个利用内存池机制来分配内存的工具类
- /***********************************************************************/
- #ifndef __CBuffers__
- #define __CBuffers__
- class CBuffers
- {
- public:
- char* GetBuf(size_t lsize);
- char* Extern(size_t maxSize);
- char* Copy( void * lpData, size_t lsize );
- char* Append( void * lpData, size_t lsize );
- void Attach( CBuffers*pMemory );
- void Detach();
- void Release(void);
- inline operator const char * (void) const;
- const CBuffers& operator=(const char * lpString);
- const CBuffers& operator+=(const char * lpString);
- //绑定地址:自动释放
- CBuffers(void * lpBuffer=0);
- ~CBuffers(void);
- size_t sizeData,sizeMalloc;
- char *bufData;
- };
- #define FREE_BUFFER( x ) \
- { \
- CBuffers buf( x ); \
- }
- #define INIT_BUFFER( x, n ) \
- { \
- CBuffers buf; \
- x = buf.GetBuf( ( n ) ); \
- buf.Detach(); \
- }
- #endif //__CBuffers__
|