- if(pixel_list_root == NULL)
- { pixel_list_root = pixel_node;
- }
-
- prev_node = head_node = pixel_list_root;
- while(head_node != NULL)
- { if(pixel_node->data.z > head_node->data.z)
- { if(head_node->next)
- { prev_node = head_node;
- head_node = head_node->next;
- }
- else
- { head_node->next = pixel_node;
- break;
- }
- }
- else if (pixel_node->data.z < head_node->data.z)
- { pixel_node->num++;
- prev_node->next = pixel_node;
- pixel_node->next = head_node;
- break;
- }
- else // pixel_node->data.z == head_node->data.z
- { pixel_node->num = head_node->num + 1;
- prev_node->next = pixel_node;
- pixel_node->next = head_node;
- }
- }
+ while(*head_node != NULL && head_node->data.ref < pixel_node->data.ref)
+ head_node = &((*head_node)->next);
+
+ pixel_node->next = *head_node;
+ *head_node = pixel_node;