mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-10-27 16:58:31 -04:00
Remove unused includes and apply google code style
This commit is contained in:
1 parent
271dcbc4e8
commit
2cdf0da3c0
1 file changed
+14
-25
+14
-25
@@ -17,62 +17,51 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "zm.h"
|
||||
#include "zm_buffer.h"
|
||||
|
||||
unsigned int Buffer::assign( const unsigned char *pStorage, unsigned int pSize )
|
||||
{
|
||||
if ( mAllocation < pSize )
|
||||
{
|
||||
unsigned int Buffer::assign(const unsigned char *pStorage, unsigned int pSize) {
|
||||
if ( mAllocation < pSize ) {
|
||||
delete[] mStorage;
|
||||
mAllocation = pSize;
|
||||
mHead = mStorage = new unsigned char[pSize];
|
||||
}
|
||||
mSize = pSize;
|
||||
memcpy( mStorage, pStorage, mSize );
|
||||
memcpy(mStorage, pStorage, mSize);
|
||||
mHead = mStorage;
|
||||
mTail = mHead + mSize;
|
||||
return( mSize );
|
||||
return mSize;
|
||||
}
|
||||
|
||||
unsigned int Buffer::expand( unsigned int count )
|
||||
{
|
||||
unsigned int Buffer::expand(unsigned int count) {
|
||||
int spare = mAllocation - mSize;
|
||||
int headSpace = mHead - mStorage;
|
||||
int tailSpace = spare - headSpace;
|
||||
int width = mTail - mHead;
|
||||
if ( spare > (int)count )
|
||||
{
|
||||
if ( tailSpace < (int)count )
|
||||
{
|
||||
memmove( mStorage, mHead, mSize );
|
||||
if ( spare > static_cast<int>count ) {
|
||||
if ( tailSpace < static_cast<int>count ) {
|
||||
memmove(mStorage, mHead, mSize);
|
||||
mHead = mStorage;
|
||||
mTail = mHead + width;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
mAllocation += count;
|
||||
unsigned char *newStorage = new unsigned char[mAllocation];
|
||||
if ( mStorage )
|
||||
{
|
||||
memcpy( newStorage, mHead, mSize );
|
||||
if ( mStorage ) {
|
||||
memcpy(newStorage, mHead, mSize);
|
||||
delete[] mStorage;
|
||||
}
|
||||
mStorage = newStorage;
|
||||
mHead = mStorage;
|
||||
mTail = mHead + width;
|
||||
}
|
||||
return( mSize );
|
||||
return mSize;
|
||||
}
|
||||
|
||||
int Buffer::read_into( int sd, unsigned int bytes ) {
|
||||
int Buffer::read_into(int sd, unsigned int bytes) {
|
||||
// Make sure there is enough space
|
||||
this->expand(bytes);
|
||||
int bytes_read = read( sd, mTail, bytes );
|
||||
int bytes_read = read(sd, mTail, bytes);
|
||||
if ( bytes_read > 0 ) {
|
||||
mTail += bytes_read;
|
||||
mSize += bytes_read;
|
||||
|
||||
Reference in new issue
Block a user