MCPcopy Create free account
hub / github.com/ValveSoftware/GameNetworkingSockets / DecimalToUint64

Function DecimalToUint64

src/common/steamid.cpp:16–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14#include "steamid.h"
15
16static const char *DecimalToUint64( const char *pchStr, uint64 unLimit,
17 uint64 *punVal )
18{
19 const char *pchStart = pchStr;
20 uint64 unVal = 0;
21
22 while ( *pchStr >= '0' && *pchStr <= '9' )
23 {
24 uint64 unNext = unVal * 10;
25
26 if ( unNext < unVal )
27 {
28 // 64-bit overflow.
29 return NULL;
30 }
31
32 unVal = unNext + (uint64)( *pchStr - '0' );
33 if ( unVal > unLimit )
34 {
35 // Limit overflow.
36 return NULL;
37 }
38
39 pchStr++;
40 }
41 if ( pchStr == pchStart )
42 {
43 // No number at all.
44 return NULL;
45 }
46
47 *punVal = unVal;
48 return pchStr;
49}
50
51//-----------------------------------------------------------------------------
52// Purpose: Constructor

Callers 1

SetFromStringStrictMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected