Monitoring function for pointers (CheckPointer)
Use this function to monitor the memory access of pointers in runtime mode. As opposed
to other ⮫ monitoring functions, ⮫ monitoring functions, a standard suggestion does not exist for the implementation of CheckPointer
. You must define an implementation according to your own requirements.
The CheckPointer
function should check whether or not the passed pointer references a valid memory
address, and whether or not the orientation of the referenced memory area matches
the variable type to which the pointer refers. If both conditions are fulfilled, then
the pointer is returned. If not, then the function should complete an appropriate
error handling.




CAUTION

To get the feature for monitoring functions, do not edit the declaration part. However, you are permitted to add local variables.




NOTICE

An implicit monitoring function call does not occur for THIS pointer and SUPER pointer.




NOTICE

In compiler version 3.5.7.40 and higher, the “CheckPointer” also affects REFERENCE
variables the same as pointer variables.
Template
Declaration:
// Automatisch erzeugter Code: NICHT EDITIEREN FUNCTION CheckPointer : POINTER TO BYTE VAR_INPUT ptToTest : POINTER TO BYTE; iSize : DINT; iGran : DINT; bWrite: BOOL; END_VAR
Implementation: (incomplete)
// Keine Standardimplementierung. Bitte fügen Sie Ihren Code hier ein. CheckPointer := ptToTest;
When the function is called, it receives the following input parameters:
-
ptToTest
: Target address of the pointer -
iSize
: Size of the referenced variable; the data type ofiSize
must be compatible withINT
and cover the dimensional scope of the variables -
iGran
: Granularity of the referenced size; this is the largest non-structured data type contained in the referenced variables; the data type ofiGran
must be compatible withINT
-
bWrite
: Access type (TRUE
= write access,FALSE
= read access); the data type ofbWrite
has to beBOOL
When the result of the check is positive, the unchanged pointer is returned (ptToTest
).