mirror of
https://github.com/dashr9230/SA-MP.git
synced 2025-01-11 11:32:35 +08:00
[raknet] Implement BitStream::SetNumberOfBitsAllocated()
This commit is contained in:
parent
56e0bf3910
commit
3397c93362
@ -110,6 +110,15 @@ BitStream::BitStream( char* _dataC, unsigned int lengthInBytes, bool _copyData )
|
||||
data = ( unsigned char* ) _data;
|
||||
}
|
||||
|
||||
// Use this if you pass a pointer copy to the constructor (_copyData==false) and want to overallocate to prevent reallocation
|
||||
void BitStream::SetNumberOfBitsAllocated( const unsigned int lengthInBits )
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
assert( lengthInBits >= ( unsigned int ) numberOfBitsAllocated );
|
||||
#endif
|
||||
numberOfBitsAllocated = lengthInBits;
|
||||
}
|
||||
|
||||
BitStream::~BitStream()
|
||||
{
|
||||
if ( copyData && numberOfBitsAllocated > BITSTREAM_STACK_ALLOCATION_SIZE << 3)
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "Export.h"
|
||||
#include "NetworkTypes.h"
|
||||
#include <assert.h>
|
||||
|
||||
/// Arbitrary size, just picking something likely to be larger than most packets
|
||||
#define BITSTREAM_STACK_ALLOCATION_SIZE 256
|
||||
@ -46,6 +47,10 @@ namespace RakNet
|
||||
/// Destructor
|
||||
~BitStream();
|
||||
|
||||
/// Use this if you pass a pointer copy to the constructor
|
||||
/// *(_copyData==false) and want to overallocate to prevent
|
||||
/// *reallocation
|
||||
void SetNumberOfBitsAllocated( const unsigned int lengthInBits );
|
||||
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user