Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This comment seems wrong to me:

      // The "indirect" pointer points to the
      // *address* of the thing we'll update
The "indirect" pointer points to the thing we'll update. See at the bottom, it's updating *indirect, so "indirect" points to the thing being updated. On the other hand, "indirect" points to the address of the thing we'll remove. There's a specific item being removed, and there's a specific thing that will be updated; the thing being updated comes immediately before the thing being removed; they're not the same thing.


The comment is correct. The "thing" is the variable that holds the "entry". The entry is removed by updating the "thing".


Agreed. The 'indirect pointer' points to the memory address of the previous 'next' (or the head). So, as long as neither are NULL, then dereferencing the pointer is the actual head (or the previous 'next').


> The 'indirect pointer' points to the memory address of the previous 'next' (or the head).

I don't think so. I think the 'indirect pointer' points to the previous 'next' (or the head). It doesn't point to the address of the previous 'next' (or the head). What you say is adding an additional level of indirection that doesn't exist.

Reality:

indirect -> previous next -> first element

What you're saying:

indirect -> address of previous next -> previous next -> first element

In reality indirect contains the address of the previous next, but it doesn't point to the address of the previous next.


The "indirect" variable does not point to a list entry directly, like what "head" and "next" variables do, that's why it's named "indirect".


I agree:

indirect -> previous next -> first element

"indirect" points to "previous next". "previous next" isn't a list entry. "previous next" points to "first element", which is a list entry.


> The "thing" is the variable that holds the "entry".

What does "holds" mean? If holds means actually contains the memory, then I don't see the distinction between "thing" and "entry". They both refer to the exact same piece of memory.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: