Permalink
Browse files

fixed remaining unaligned write in pkts

added memorysize logging of our BObject allocators
  • Loading branch information...
turleypol committed Feb 10, 2019
1 parent 864aa7a commit 3ce313ff5c4d09d14207abebb8037e057ac8350c
Showing with 13 additions and 7 deletions.
  1. +7 −5 pol-core/clib/fixalloc.h
  2. +4 −0 pol-core/pol/globals/memoryusage.cpp
  3. +2 −2 pol-core/pol/network/packets.h
@@ -49,11 +49,13 @@ class fixed_allocator
void log_stuff( const std::string& detail );
#endif

size_t memsize = 0;

protected:
void* refill( void );

private:
Buffer* freelist_;
Buffer* freelist_ = nullptr;
#ifdef MEMORYLEAK
int buffers;
int requests;
@@ -117,12 +119,12 @@ void* fixed_allocator<N, B>::refill()
{
size_t nbytes = sizeof( Buffer[B] );

Buffer* morebuf = static_cast<Buffer*>(::operator new( nbytes ) );
Buffer* morebuf = static_cast<Buffer*>( ::operator new( nbytes ) );

#ifdef MEMORYLEAK
buffers++;
#endif

memsize += nbytes;
Buffer* walk = morebuf + 1;
int count = B - 2;
while ( count-- )
@@ -176,6 +178,6 @@ void fixed_allocator<N, B>::deallocate( void* vp, size_t size )
else
::operator delete( vp );
}
}
}
} // namespace Clib
} // namespace Pol
#endif
@@ -77,6 +77,10 @@ void MemoryUsage::log()
logs.push_back( std::make_pair( "ObjArmorSize", object_sizes.obj_armor_size ) );
logs.push_back( std::make_pair( "ObjMultiCount", object_sizes.obj_multi_count ) );
logs.push_back( std::make_pair( "ObjMultiSize", object_sizes.obj_multi_size ) );
logs.push_back( std::make_pair( "BObjectAllocatorSize", Bscript::bobject_alloc.memsize ) );
logs.push_back( std::make_pair( "UninitAllocatorSize", Bscript::uninit_alloc.memsize ) );
logs.push_back( std::make_pair( "BLongAllocatorSize", Bscript::blong_alloc.memsize ) );
logs.push_back( std::make_pair( "BDoubleAllocatorSize", Bscript::double_alloc.memsize ) );
#ifdef ENABLE_FLYWEIGHT_REPORT
auto flydata = boost_utils::Query::getCountAndSize();
int i = 0;
@@ -7,7 +7,6 @@
#ifndef POL_PACKETS_H
#define POL_PACKETS_H

#include <boost/noncopyable.hpp>
#include <cstring>
#include <limits>
#include <map>
@@ -314,7 +313,8 @@ class PacketTemplateSub final : public PacketWriter<_id, _size, _sub>
{
memset( PacketWriter<_id, _size, _sub>::buffer, 0, _size );
PacketWriter<_id, _size, _sub>::buffer[0] = _id;
( *(u16*)(void*)&PacketWriter<_id, _size, _sub>::buffer[_suboff] ) = cfBEu16( _sub );
u16 sub = cfBEu16( _sub );
std::memcpy( &PacketWriter<_id, _size, _sub>::buffer[_suboff], &sub, sizeof( sub ) );
PacketWriter<_id, _size, _sub>::offset = 1;
};
virtual inline u16 getSubID() const override { return _sub; };

0 comments on commit 3ce313f

Please sign in to comment.