mirror of
https://github.com/dashr9230/SA-MP.git
synced 2026-10-11 01:38:17 +08:00
[raknet] Implement BitStream::SetNumberOfBitsAllocated()
This commit is contained in:
1 parent
56e0bf3910
commit
3397c93362
2 files changed
+14
No files matched your search
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user