The first N nodes in pNodes will be the heads of the lists.
| 114 | |
| 115 | // The first N nodes in pNodes will be the heads of the lists. |
| 116 | void create_linked_lists(Node* pNodes, size_t num_lists, int list_length) |
| 117 | { |
| 118 | size_t allocation_index = num_lists; // heads of lists are in first num_lists nodes. |
| 119 | |
| 120 | for(cl_uint i = 0; i < num_lists; i++) |
| 121 | { |
| 122 | Node *pNode = &pNodes[i]; |
| 123 | pNode->global_id = i; |
| 124 | pNode->position_in_list = 0; |
| 125 | Node *pNew; |
| 126 | for(int j=1; j < list_length; j++) |
| 127 | { |
| 128 | pNew = &pNodes[ allocation_index++ ];// allocate a new node |
| 129 | pNew->global_id = i; |
| 130 | pNew->position_in_list = j; |
| 131 | pNode->pNext = pNew; // link new node onto end of list |
| 132 | pNode = pNew; // move to end of list |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | cl_int verify_linked_lists(Node* pNodes, size_t num_lists, int list_length) |
| 138 | { |
no outgoing calls