MCPcopy Create free account
hub / github.com/CruiserOne/Astrolog / PAllocate

Function PAllocate

general.cpp:3156–3188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3154// a size, and a string to use when printing error if the allocation fails.
3155
3156pbyte PAllocate(long cb, CONST char *szType)
3157{
3158 char szT[cchSzDef];
3159 pbyte pb;
3160
3161#ifdef DEBUG
3162 pb = (pbyte)PAllocateCore(cb + sizeof(dword)*3);
3163#else
3164 pb = (pbyte)PAllocateCore(cb);
3165#endif
3166
3167 // Handle success or failure of the allocation.
3168 Assert(szType != NULL);
3169 if (pb == NULL) {
3170 sprintf(szT, "%s: Not enough memory for %s (%ld bytes).",
3171 szAppName, szType, cb);
3172 PrintWarning(szT);
3173 } else {
3174 is.cAlloc++;
3175 is.cAllocTotal++;
3176 is.cbAllocSize += cb;
3177 }
3178
3179#ifdef DEBUG
3180 // Put sentinels at ends of allocation to check for buffer overruns.
3181 *(dword *)pb = dwCanary;
3182 *(dword *)(pb + sizeof(dword)) = cb;
3183 *(dword *)(pb + sizeof(dword)*2 + cb) = dwCanary;
3184 return pb + sizeof(dword)*2;
3185#else
3186 return pb;
3187#endif
3188}
3189
3190
3191// Free a memory buffer allocated with PAllocate().

Callers 11

FProcessYXUFunction · 0.85
xscreen.cppFile · 0.85
ChartTransitGraphFunction · 0.85
FCloneSzCoreFunction · 0.85
SzCloneFunction · 0.85
RgReallocateFunction · 0.85
FEnsureGridFunction · 0.85
DlgSaveChartFunction · 0.85
XChartTransitFunction · 0.85
FAllocateBmpFunction · 0.85
WritePNGFunction · 0.85

Calls 2

AssertFunction · 0.85
PrintWarningFunction · 0.85

Tested by

no test coverage detected