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:
New(newBack); curBackPtr^ := newBack; curBackPtr := @(newBack^.next);
What scares me is what newBack
gets assigned curBackPtr
and immediately thereafter gets newBack.next
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
New(newBack);
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.
source to share