• R/O
  • SSH
  • HTTPS

eirrepo: Commit


Commit MetaInfo

Revision101 (tree)
Time2018-05-16 02:28:57
Authorquiret

Log Message

- renovated some source code

Microsoft keeps breaking their compiler. It is very annoying. Getting an "Internal compiler error." ... msc1.cpp line 1516

Change Summary

Incremental Difference

--- common/sdk/MemoryUtils.h (revision 100)
+++ common/sdk/MemoryUtils.h (revision 101)
@@ -289,7 +289,7 @@
289289 {
290290 blockIter_t curItem = this->iter;
291291
292- void *curBlock = NULL;
292+ void *curBlock = nullptr;
293293
294294 if ( !this->manager->IsEndMemoryBlock( curItem ) )
295295 {
@@ -303,13 +303,13 @@
303303
304304 bool shouldBreak = false;
305305
306- void *nextBlock = NULL;
306+ void *nextBlock = nullptr;
307307
308308 if ( !this->manager->IsEndMemoryBlock( nextItem ) )
309309 {
310310 nextBlock = nextItem.GetNativePointer();
311311
312- if ( curBlock == NULL )
312+ if ( curBlock == nullptr )
313313 {
314314 this->removalByteCount = 0;
315315 }
@@ -352,7 +352,7 @@
352352 {
353353 blockIter_t curItem = this->iter;
354354
355- void *curBlock = NULL;
355+ void *curBlock = nullptr;
356356
357357 if ( !this->manager->IsEndMemoryBlock( curItem ) )
358358 {
@@ -366,13 +366,13 @@
366366
367367 bool shouldBreak = false;
368368
369- void *prevBlock = NULL;
369+ void *prevBlock = nullptr;
370370
371371 if ( !this->manager->IsEndMemoryBlock( prevItem ) )
372372 {
373373 prevBlock = prevItem.GetNativePointer();
374374
375- if ( curBlock == NULL )
375+ if ( curBlock == nullptr )
376376 {
377377 // TODO annoying shit.
378378 // basically I must restore the state as if the guy went through the list straight.
@@ -808,7 +808,7 @@
808808 {
809809 // We cannot allocate zero size.
810810 if ( memSize == 0 )
811- return NULL;
811+ return nullptr;
812812
813813 // Get the actual mem block size.
814814 size_t actualMemSize = ( memSize + sizeof( memoryEntry ) );
@@ -820,7 +820,7 @@
820820 // The space allocation could fail if there is not enough space given by the size_t type.
821821 // This is very unlikely to happen, but must be taken care of.
822822 if ( hasSpace == false )
823- return NULL;
823+ return nullptr;
824824
825825 // Make sure we allocate in the valid region.
826826 {
@@ -829,7 +829,7 @@
829829 if ( intResult != memSlice_t::INTERSECT_EQUAL &&
830830 intResult != memSlice_t::INTERSECT_INSIDE )
831831 {
832- return NULL;
832+ return nullptr;
833833 }
834834 }
835835
@@ -1240,7 +1240,7 @@
12401240
12411241 inline AnonymousPluginStructRegistry( void )
12421242 {
1243- this->preferredAlignment = (pluginOffset_t)4;
1243+ this->preferredAlignment = (pluginOffset_t)sizeof(void*);
12441244 }
12451245
12461246 inline ~AnonymousPluginStructRegistry( void )
@@ -1311,7 +1311,7 @@
13111311 right.pluginSize = 0; // this means invalidation.
13121312 right.pluginId = pluginDescriptorType(); // TODO: probably set this to invalid id.
13131313 right.pluginOffset = 0;
1314- right.descriptor = NULL;
1314+ right.descriptor = nullptr;
13151315 }
13161316 inline registered_plugin( const registered_plugin& right ) = delete;
13171317
@@ -1354,7 +1354,7 @@
13541354 inline pluginOffset_t RegisterPlugin( size_t pluginSize, const pluginDescriptorType& pluginId, pluginInterface *plugInterface )
13551355 {
13561356 // Make sure we have got valid parameters passed.
1357- if ( pluginSize == 0 || plugInterface == NULL )
1357+ if ( pluginSize == 0 || plugInterface == nullptr )
13581358 return 0; // TODO: fix this crap, 0 is ambivalent since its a valid index!
13591359
13601360 // Determine the plugin offset that should be used for allocation.
@@ -1817,7 +1817,7 @@
18171817 {
18181818 typedef classType hostType_t;
18191819
1820- static const unsigned int ANONYMOUS_PLUGIN_ID = 0xFFFFFFFF;
1820+ static constexpr unsigned int ANONYMOUS_PLUGIN_ID = 0xFFFFFFFF;
18211821
18221822 std::atomic <unsigned int> aliveClasses;
18231823
@@ -1881,7 +1881,7 @@
18811881 // Localize certain plugin registry types.
18821882 typedef typename structRegistry_t::pluginInterface pluginInterface;
18831883
1884- static const pluginOffset_t INVALID_PLUGIN_OFFSET = (pluginOffset_t)-1;
1884+ static constexpr pluginOffset_t INVALID_PLUGIN_OFFSET = (pluginOffset_t)-1;
18851885
18861886 AINLINE static bool IsOffsetValid( pluginOffset_t offset )
18871887 {
@@ -1892,7 +1892,7 @@
18921892 AINLINE static pluginStructType* RESOLVE_STRUCT( classType *object, pluginOffset_t offset )
18931893 {
18941894 if ( IsOffsetValid( offset ) == false )
1895- return NULL;
1895+ return nullptr;
18961896
18971897 return (pluginStructType*)( (char*)object + sizeof( classType ) + offset );
18981898 }
@@ -1901,7 +1901,7 @@
19011901 AINLINE static const pluginStructType* RESOLVE_STRUCT( const classType *object, pluginOffset_t offset )
19021902 {
19031903 if ( IsOffsetValid( offset ) == false )
1904- return NULL;
1904+ return nullptr;
19051905
19061906 return (const pluginStructType*)( (const char*)object + sizeof( classType ) + offset );
19071907 }
@@ -1918,7 +1918,7 @@
19181918 AINLINE static const classType* BACK_RESOLVE_STRUCT( const void *pluginObj, pluginOffset_t offset )
19191919 {
19201920 if ( IsOffsetValid( offset ) == false )
1921- return NULL;
1921+ return nullptr;
19221922
19231923 return (const classType*)( (const char*)pluginObj - ( sizeof( classType ) + offset ) );
19241924 }
@@ -1978,9 +1978,9 @@
19781978 template <typename constructorType>
19791979 inline classType* ConstructPlacementEx( void *classMem, const constructorType& constructor )
19801980 {
1981- classType *resultObject = NULL;
1981+ classType *resultObject = nullptr;
19821982 {
1983- classType *intermediateClassObject = NULL;
1983+ classType *intermediateClassObject = nullptr;
19841984
19851985 try
19861986 {
@@ -1989,7 +1989,7 @@
19891989 catch( ... )
19901990 {
19911991 // The base object failed to construct, so terminate here.
1992- intermediateClassObject = NULL;
1992+ intermediateClassObject = nullptr;
19931993 }
19941994
19951995 if ( intermediateClassObject )
@@ -2027,7 +2027,7 @@
20272027 void *classMem = memAllocator.Allocate( wholeClassSize );
20282028
20292029 if ( !classMem )
2030- return NULL;
2030+ return nullptr;
20312031
20322032 classType *resultObj = ConstructPlacementEx( classMem, constructor );
20332033
@@ -2074,10 +2074,10 @@
20742074 template <typename constructorType>
20752075 inline classType* ClonePlacementEx( void *classMem, const classType *srcObject, const constructorType& constructor )
20762076 {
2077- classType *clonedObject = NULL;
2077+ classType *clonedObject = nullptr;
20782078 {
20792079 // Construct a basic class where we assign stuff to.
2080- classType *dstObject = NULL;
2080+ classType *dstObject = nullptr;
20812081
20822082 try
20832083 {
@@ -2085,7 +2085,7 @@
20852085 }
20862086 catch( ... )
20872087 {
2088- dstObject = NULL;
2088+ dstObject = nullptr;
20892089 }
20902090
20912091 if ( dstObject )
@@ -2101,19 +2101,19 @@
21012101 clonedObject = dstObject;
21022102 }
21032103
2104- if ( clonedObject == NULL )
2104+ if ( clonedObject == nullptr )
21052105 {
21062106 structRegistry.DestroyPluginBlock( dstObject );
21072107 }
21082108 }
21092109
2110- if ( clonedObject == NULL )
2110+ if ( clonedObject == nullptr )
21112111 {
21122112 // Since cloning plugin data has not succeeded, we have to destroy the constructed base object again.
21132113 // Make sure that we do not throw exceptions.
21142114 DestroyBaseObject( dstObject );
21152115
2116- dstObject = NULL;
2116+ dstObject = nullptr;
21172117 }
21182118 }
21192119 }
@@ -2136,11 +2136,11 @@
21362136 void *classMem = memAllocator.Allocate( wholeClassSize );
21372137
21382138 if ( !classMem )
2139- return NULL;
2139+ return nullptr;
21402140
21412141 classType *clonedObject = ClonePlacementEx( classMem, srcObject, constructor );
21422142
2143- if ( clonedObject == NULL )
2143+ if ( clonedObject == nullptr )
21442144 {
21452145 memAllocator.Free( classMem );
21462146 }
@@ -2233,7 +2233,7 @@
22332233 template <typename allocatorType>
22342234 inline void Destroy( allocatorType& memAllocator, classType *classObject )
22352235 {
2236- if ( classObject == NULL )
2236+ if ( classObject == nullptr )
22372237 return;
22382238
22392239 // Invalidate the memory that is in "classObject".
@@ -2288,7 +2288,7 @@
22882288 {
22892289 typedef DeferredConstructor <allocatorType> Constructor;
22902290
2291- Constructor *result = NULL;
2291+ Constructor *result = nullptr;
22922292
22932293 {
22942294 void *constructorMem = memAllocator.Allocate( sizeof( Constructor ) );
@@ -2346,7 +2346,7 @@
23462346
23472347 AINLINE growableArrayEx( void )
23482348 {
2349- data = NULL;
2349+ data = nullptr;
23502350 numActiveEntries = 0;
23512351 sizeCount = 0;
23522352 }
@@ -2353,7 +2353,7 @@
23532353
23542354 AINLINE growableArrayEx( allocatorType allocNode ) : _memAllocator( std::move( allocNode ) )
23552355 {
2356- data = NULL;
2356+ data = nullptr;
23572357 numActiveEntries = 0;
23582358 sizeCount = 0;
23592359 }
@@ -2364,7 +2364,7 @@
23642364 this->numActiveEntries = right.numActiveEntries;
23652365 this->sizeCount = right.sizeCount;
23662366
2367- right.data = NULL;
2367+ right.data = nullptr;
23682368 right.numActiveEntries = 0;
23692369 right.sizeCount = 0;
23702370 }
@@ -2371,7 +2371,7 @@
23712371
23722372 AINLINE growableArrayEx( const growableArrayEx& right )
23732373 {
2374- this->data = NULL;
2374+ this->data = nullptr;
23752375 this->numActiveEntries = 0;
23762376 this->sizeCount = 0;
23772377
@@ -2400,7 +2400,7 @@
24002400 this->numActiveEntries = right.numActiveEntries;
24012401 this->sizeCount = right.sizeCount;
24022402
2403- right.data = NULL;
2403+ right.data = nullptr;
24042404 right.numActiveEntries = 0;
24052405 right.sizeCount = 0;
24062406 }
@@ -2476,7 +2476,7 @@
24762476 {
24772477 _memFree( data );
24782478
2479- data = NULL;
2479+ data = nullptr;
24802480 }
24812481 }
24822482 else
Show on old repository browser