3 ms·
I'm kinda confused on how this will behave if we want to remove `head`—if `head` is in the stack frame (assuming it's a parameter to `remove_list_entry`), would
by BalinKing 6y ago
I'm kinda confused on how this will behave if we want to remove `head`—if `head` is in the stack frame (assuming it's a parameter to `remove_list_entry`), wouldn't `*(&head) = entry->next;` be a no-op as far as the caller is concerned? (Sorry for the n00b question.)
- kbumsik 6y agoThen you will escape from while((* indirect) != entry) check in the first place and ignore * (&head) = entry->next;.
- foota 6y agoNo, this copies the value from next into the memory occupied by head. For example if the linked list was: &next: (100, 0xFFFF) 0xFFFF: (101, 0xDEFF) 0XDEFF: (102, 0) Then calling remove on head would leave us with: &next: (101, 0xDEFF) 0xFFFF: (101, 0xDEFF) 0XDEFF: (102, 0) (It would be on the caller to free the memory address 0XFFFF)