Last active
May 6, 2017 08:14
-
-
Save Lifelovinglight/db352afe00528e9be12f19c659ebf733 to your computer and use it in GitHub Desktop.
so confuse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct struct_i_want_to_put_inna_list { | |
struct list_head nextelem; | |
int mydata; | |
}; | |
struct list_head my_list; | |
INIT_LIST_HEAD(&my_list); | |
struct struct_i_want_to_put_inna_list *current_elem; | |
int sum_of_two_first_elements = 0; | |
current_elem = first_entry_or_null(my_list, struct struct_i_want_to_put_inna_list, nextelem); | |
sum_of_two_first_elements += current_elem->mydata; | |
current_elem = first_entry_or_null(current_elem->nextelem, struct struct_i_want_to_put_inna_list, nextelem); | |
sum_of_two_first_elements += current_elem->mydata; | |
//and now sum_of_two_first_elements contains the sum of the mydata fields in the two first cells of the linked list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment