could you tell what causes the above error appeared?
The errors marked are unfreed memory block detected by HeapTrace.
One on line 16: Wrong size : 8 allocated 4 freed
IF P^.NEXT=NIL THEN EXIT();
PRINTING(P); //<===== LINE 16
FREEMEM(P,SIZEOF(LINKED_PTR));
though it states "Line 16" maybe the problem is the following line. I never used Freemem but it seems you are not freeing the right size. My guess is that you are creating a memory space of 8 bytes for a "LINK_NODE" and you are freeing a memory space of 4 Bytes the size of "LINKED_PTR".
The other on line 33:
PROCEDURE ASSIGNMENT(PTR:LINKED_PTR;N:INTEGER);
VAR K:INTEGER;
BEGIN
FOR K:=1 TO N DO
BEGIN
SUCCESSOR(PTR); //<====== Line 33
END;
END;
Take a look to what happens to "PTR". Without checking the logic I can tell that there might be a problem with how parameters are passed: "procedure ASSIGNMENT" receives the parameter "PTR" by value then you call "SUCCESOR" which receives the parameter "PTR" by VARIABLE and set a new value for ASSIGNMENT's PTR parameter whic value is lost after leaving the procedure.
Check what you wanted to do and what you are actually doing.
Note that if you change ASSIGNMENT's function declaration to:
PROCEDURE ASSIGNMENT(const PTR:LINKED_PTR;N:INTEGER);
it will no longer compile.
EDIT: if you are using typed pointers then it is better to use "New(PTR)" to create the pointer and space in memory and use "Dispose(PTR)" to release that memory without errors in the memory size.