diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-05-05 20:09:38 -0600 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-05-05 22:47:44 -0600 |
commit | 6c2943e735c99579b5b861f67f2d98e5ddd6306f (patch) | |
tree | e882a1dda2726dd9dfca3fe2dd44750b17b1edda /libdimension/prtree.c | |
parent | b14506e501770aeaf54d1160c0073398cc29a038 (diff) | |
download | dimension-6c2943e735c99579b5b861f67f2d98e5ddd6306f.tar.xz |
Use C99 for loop initializers.
Diffstat (limited to 'libdimension/prtree.c')
-rw-r--r-- | libdimension/prtree.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/libdimension/prtree.c b/libdimension/prtree.c index baf41b0..6c9371c 100644 --- a/libdimension/prtree.c +++ b/libdimension/prtree.c @@ -219,8 +219,10 @@ dmnsn_priority_search(dmnsn_list *leaves, bool are_objects, int comparator) if (i) { double candidate = dmnsn_priority_get(i, are_objects, comparator); - dmnsn_list_iterator *j; - for (j = dmnsn_list_next(i); j != NULL; j = dmnsn_list_next(j)) { + for (dmnsn_list_iterator *j = dmnsn_list_next(i); + j != NULL; + j = dmnsn_list_next(j)) + { double new_candidate = dmnsn_priority_get(j, are_objects, comparator); if (new_candidate < candidate) { candidate = new_candidate; @@ -286,13 +288,12 @@ dmnsn_new_pseudo_prtree(dmnsn_list *leaves, bool are_objects, int comparator) } else { /* Make an internal node */ pseudo->is_leaf = false; - size_t i; - for (i = 0; i < 6; ++i) { + for (size_t i = 0; i < 6; ++i) { pseudo->node.children[i].is_leaf = are_objects; } /* Fill the priority leaves */ - size_t j; + size_t i, j; for (i = 0; i < DMNSN_PRTREE_B; ++i) { for (j = 0; j < 6; ++j) { dmnsn_list_iterator *k = dmnsn_priority_search(leaves, are_objects, j); @@ -377,8 +378,7 @@ dmnsn_new_prtree_node(const dmnsn_pseudo_prleaf *leaf) node->is_leaf = leaf->is_leaf; node->bounding_box = leaf->bounding_box; - size_t i; - for (i = 0; i < DMNSN_PRTREE_B; ++i) { + for (size_t i = 0; i < DMNSN_PRTREE_B; ++i) { node->children[i] = leaf->children[i]; } @@ -403,8 +403,7 @@ dmnsn_pseudo_prtree_leaves_recursive(const dmnsn_pseudo_prtree *node, if (node->is_leaf) { dmnsn_pseudo_prtree_add_leaf(&node->leaf, leaves); } else { - size_t i; - for (i = 0; i < 6; ++i) { + for (size_t i = 0; i < 6; ++i) { dmnsn_pseudo_prtree_add_leaf(&node->node.children[i], leaves); } dmnsn_pseudo_prtree_leaves_recursive(node->node.left, leaves); @@ -431,8 +430,7 @@ dmnsn_pseudo_prtree_leaves(const dmnsn_pseudo_prtree *pseudo) dmnsn_prtree * dmnsn_new_prtree(const dmnsn_array *objects) { - size_t i; - for (i = 0; i < dmnsn_array_size(objects); ++i) { + for (size_t i = 0; i < dmnsn_array_size(objects); ++i) { dmnsn_object *object; dmnsn_array_get(objects, i, &object); dmnsn_object_precompute(object); @@ -463,8 +461,7 @@ dmnsn_delete_prtree(dmnsn_prtree *tree) { if (tree) { if (!tree->is_leaf) { - size_t i; - for (i = 0; i < DMNSN_PRTREE_B; ++i) { + for (size_t i = 0; i < DMNSN_PRTREE_B; ++i) { dmnsn_delete_prtree(tree->children[i]); } } @@ -480,8 +477,7 @@ dmnsn_prtree_search_recursive(const dmnsn_prtree *node, dmnsn_line ray, dmnsn_intersection *intersection, double *t) { if (dmnsn_ray_box_intersection(ray, node->bounding_box, *t)) { - size_t i; - for (i = 0; i < DMNSN_PRTREE_B; ++i) { + for (size_t i = 0; i < DMNSN_PRTREE_B; ++i) { if (!node->children[i]) break; |