Buffer.cpp
资源名称:视频会议系统.rar [点击查看]
上传用户:popouu88
上传日期:2013-02-11
资源大小:2894k
文件大小:1k
源码类别:
IP电话/视频会议
开发平台:
Visual C++
- // Buffer.cpp: implementation of the CBuffer1 class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "Buffer.h"
- #include <memory.h>
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CBuffer::CBuffer( )
- {
- this->buffer = NULL ;
- this->size = 0;
- }
- CBuffer::CBuffer( int s )
- {
- this->buffer = NULL ;
- this->Resize( s );
- }
- CBuffer::CBuffer( const char * buffer , int size )
- {
- this->buffer = NULL;
- this->Resize( size );
- memcpy( this->buffer , buffer , size );
- }
- const CBuffer & CBuffer::operator =( const CBuffer & b )
- {
- this->Resize( b.size );
- memcpy( this->buffer , b.buffer , b.size );
- return * this;
- }
- CBuffer::~CBuffer( )
- {
- this->Release( );
- }
- void CBuffer::Resize( int size )
- {
- this->Release( );
- if( size > 0 )
- {
- this->size = size;
- this->buffer = new char[ size ];
- }
- }
- void CBuffer::Release( void )
- {
- if( this->buffer )
- {
- try
- {
- delete [ ]this->buffer; this->buffer = NULL;
- }
- catch( ... )
- {
- }
- this->size = 0;
- }
- }