MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / countUnflaggedAllocs

Function countUnflaggedAllocs

Engine/source/platform/platformMemory.cpp:969–1052  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

967}
968
969S32 countUnflaggedAllocs(const char * filename, S32 *outUnflaggedRealloc, EFlag flag)
970{
971 S32 unflaggedAllocCount = 0;
972 S32 unflaggedReAllocCount = 0;
973
974 FileStream fws;
975 bool useFile = filename && *filename;
976 if (useFile)
977 useFile = fws.open(filename, Torque::FS::File::Write);
978 char buffer[1024];
979
980 U32 bit = flagToBit( flag );
981
982 PageRecord* walk;
983 for (walk = gPageList; walk; walk = walk->prevPage)
984 {
985 for(Header *probe = walk->headerList; probe; probe = probe->next)
986 {
987 if (probe->flags & Allocated)
988 {
989 AllocatedHeader* pah = (AllocatedHeader*)probe;
990 if (!(pah->flags & bit))
991 {
992 // If you want to extract further information from an unflagged
993 // memory allocation, do the following:
994 // U8 *foo = (U8 *)pah;
995 // foo += sizeof(Header);
996 // FooObject *obj = (FooObject *)foo;
997 dSprintf(buffer, 1023, "%s%s\t%d\t%d\t%d\r\n",
998 pah->flags & Reallocated ? "[R] " : "",
999 pah->fileName != NULL ? pah->fileName : "Undetermined",
1000 pah->line, pah->realSize, pah->allocNum);
1001
1002 if( pah->flags & Reallocated )
1003 unflaggedReAllocCount++;
1004 else
1005 unflaggedAllocCount++;
1006
1007 if (useFile)
1008 {
1009 fws.write(dStrlen(buffer), buffer);
1010 fws.write(2, "\r\n");
1011 }
1012 else
1013 {
1014 if( pah->flags & Reallocated )
1015 Con::warnf(buffer);
1016 else
1017 Con::errorf(buffer);
1018 }
1019
1020#ifdef TORQUE_ENABLE_PROFILE_PATH
1021 static char line[4096];
1022 dSprintf(line, sizeof(line), " %s\r\nreal size=%d",
1023 pah->profilePath ? pah->profilePath : "unknown",
1024 pah->realSize);
1025
1026 if (useFile)

Callers 1

dumpUnflaggedAllocsFunction · 0.85

Calls 8

flagToBitFunction · 0.85
dSprintfFunction · 0.85
warnfFunction · 0.85
errorfFunction · 0.85
dStrlenFunction · 0.50
openMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected