MCPcopy Create free account
hub / github.com/beefytech/Beef / ParseMemorySpan

Method ParseMemorySpan

BeefySysLib/Common.cpp:1383–1414  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1381}
1382
1383bool Beefy::ParseMemorySpan(const StringImpl& str, void*& outPtr, int& outSize, StringImpl* outKey)
1384{
1385#ifndef BF_SMALL
1386 static int anonymousIdx = 0;
1387
1388 if (str.StartsWith("@"))
1389 {
1390 int colon = (int)str.IndexOf(':');
1391 String addrStr = str.Substring(1, colon - 1);
1392 String lenStr = str.Substring(colon + 1);
1393 outPtr = (void*)(intptr)strtoll(addrStr.c_str(), NULL, 16);
1394 outSize = (int)strtol(lenStr.c_str(), NULL, 10);
1395
1396 if (outKey != NULL)
1397 {
1398 int nextColon = (int)str.IndexOf(':', colon + 1);
1399 if (nextColon > 0)
1400 {
1401 *outKey = str.Substring(nextColon + 1);
1402 }
1403 else
1404 {
1405 int dotPos = (int)str.IndexOf('.', colon + 1);
1406 *outKey = StrFormat("ANON_%d", anonymousIdx++) + str.Substring(dotPos);
1407 }
1408 }
1409
1410 return true;
1411 }
1412#endif
1413 return false;
1414}

Callers

nothing calls this directly

Calls 4

SubstringMethod · 0.80
StartsWithMethod · 0.45
IndexOfMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected