Function that checks classes for pointers
| 318 | |
| 319 | // Function that checks classes for pointers |
| 320 | void CheckClass(char* ptr, const ExternTypeInfo& type) |
| 321 | { |
| 322 | const ExternTypeInfo *realType = &type; |
| 323 | if(type.nameHash == objectName) |
| 324 | { |
| 325 | // Get real variable type |
| 326 | realType = &NULLC::commonLinker->exTypes[*(int*)ptr]; |
| 327 | // Switch pointer to target |
| 328 | char **rPtr = (char**)(ptr + 4); |
| 329 | ptr = *rPtr; |
| 330 | // If uninitialized or points to stack memory, return |
| 331 | if(!ptr || ptr <= (char*)0x00010000 || (ptr >= unmanageableBase && ptr <= unmanageableTop)) |
| 332 | return; |
| 333 | // Get base pointer |
| 334 | unsigned int *basePtr = (unsigned int*)NULLC::GetBasePointer(ptr); |
| 335 | markerType *marker = (markerType*)((char*)basePtr - sizeof(markerType)); |
| 336 | // If there is no base pointer or memory already marked, exit |
| 337 | if(!basePtr || (*marker & 1)) |
| 338 | return; |
| 339 | // Mark memory as used |
| 340 | *marker |= 1; |
| 341 | // Fixup target |
| 342 | CheckVariable(*rPtr, *realType); |
| 343 | // Exit |
| 344 | return; |
| 345 | }else if(type.nameHash == autoArrayName){ |
| 346 | CheckArray(ptr, type); |
| 347 | // Exit |
| 348 | return; |
| 349 | } |
| 350 | // Get class member type list |
| 351 | unsigned int *memberList = &NULLC::commonLinker->exTypeExtra[realType->memberOffset + realType->memberCount]; |
| 352 | // Check pointer members |
| 353 | for(unsigned int n = 0; n < realType->pointerCount; n++) |
| 354 | { |
| 355 | // Get member type |
| 356 | ExternTypeInfo &subType = NULLC::commonLinker->exTypes[memberList[n * 2]]; |
| 357 | unsigned int pos = memberList[n * 2 + 1]; |
| 358 | // Check member |
| 359 | CheckVariable(ptr + pos, subType); |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | // Function that checks function context for pointers |
| 364 | void CheckFunction(char* ptr) |
no test coverage detected