The problem with FreePascal newbies

I need to port some code from FreePascal to C. I am a professional C developer, but I don't know anything about Pascal. Most of the code can be carried over fairly easily, but one line is giving me a headache. What exactly should it do:

curBackPtr^ := newBack; 
curBackPtr := @(newBack^.next);


What scares me is what newBack

gets assigned curBackPtr

and immediately thereafter gets

assigned curBackPtr

without curBackPtr

ever being available. Is the first job redundant and can be safely deleted? Or am I missing something here?


source to share

2 answers

enter image description here





Allocates memory for the newBack type and stores the pointer in newBack.

curBackPtr ^: = newBack;

Sets the newBack pointer to the value pointed to by curBackPtr.

curBackPtr: = @ (newBack ^ .next);

Assigns curBackPtr to point to newBack ^ .next, that is, the next pointer, not what it points to.



All Articles