MCPcopy Create free account
hub / github.com/CytopiaTeam/Cytopia / CheckMaxSize

Method CheckMaxSize

external/as_add_on/scriptarray/scriptarray.cpp:754–774  ·  view source on GitHub ↗

internal

Source from the content-addressed store, hash-verified

752
753// internal
754bool CScriptArray::CheckMaxSize(asUINT numElements)
755{
756 // This code makes sure the size of the buffer that is allocated
757 // for the array doesn't overflow and becomes smaller than requested
758
759 asUINT maxSize = 0xFFFFFFFFul - sizeof(SArrayBuffer) + 1;
760 if( elementSize > 0 )
761 maxSize /= elementSize;
762
763 if( numElements > maxSize )
764 {
765 asIScriptContext *ctx = asGetActiveContext();
766 if( ctx )
767 ctx->SetException("Too large array size");
768
769 return false;
770 }
771
772 // OK
773 return true;
774}
775
776asITypeInfo *CScriptArray::GetArrayObjectType() const
777{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected