mirror of
https://github.com/dashr9230/SA-MP.git
synced 2025-09-20 04:36:01 +08:00
[raknet] Implement BitStream::Reset()
This commit is contained in:
@ -125,6 +125,28 @@ BitStream::~BitStream()
|
|||||||
free( data ); // Use realloc and free so we are more efficient than delete and new for resizing
|
free( data ); // Use realloc and free so we are more efficient than delete and new for resizing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BitStream::Reset( void )
|
||||||
|
{
|
||||||
|
// Note: Do NOT reallocate memory because BitStream is used
|
||||||
|
// in places to serialize/deserialize a buffer. Reallocation
|
||||||
|
// is a dangerous operation (may result in leaks).
|
||||||
|
|
||||||
|
if ( numberOfBitsUsed > 0 )
|
||||||
|
{
|
||||||
|
// memset(data, 0, BITS_TO_BYTES(numberOfBitsUsed));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't free memory here for speed efficiency
|
||||||
|
//free(data); // Use realloc and free so we are more efficient than delete and new for resizing
|
||||||
|
numberOfBitsUsed = 0;
|
||||||
|
|
||||||
|
//numberOfBitsAllocated=8;
|
||||||
|
readOffset = 0;
|
||||||
|
|
||||||
|
//data=(unsigned char*)malloc(1);
|
||||||
|
// if (numberOfBitsAllocated>0)
|
||||||
|
// memset(data, 0, BITS_TO_BYTES(numberOfBitsAllocated));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,6 +47,9 @@ namespace RakNet
|
|||||||
/// Destructor
|
/// Destructor
|
||||||
~BitStream();
|
~BitStream();
|
||||||
|
|
||||||
|
/// Resets the bitstream for reuse.
|
||||||
|
void Reset( void );
|
||||||
|
|
||||||
/// Use this if you pass a pointer copy to the constructor
|
/// Use this if you pass a pointer copy to the constructor
|
||||||
/// *(_copyData==false) and want to overallocate to prevent
|
/// *(_copyData==false) and want to overallocate to prevent
|
||||||
/// *reallocation
|
/// *reallocation
|
||||||
|
Reference in New Issue
Block a user