| 78 | } |
| 79 | |
| 80 | static struct cache_tree_sub *find_subtree(struct cache_tree *it, |
| 81 | const char *path, |
| 82 | int pathlen, |
| 83 | int create) |
| 84 | { |
| 85 | struct cache_tree_sub *down; |
| 86 | int pos = cache_tree_subtree_pos(it, path, pathlen); |
| 87 | if (0 <= pos) |
| 88 | return it->down[pos]; |
| 89 | if (!create) |
| 90 | return NULL; |
| 91 | |
| 92 | pos = -pos-1; |
| 93 | ALLOC_GROW(it->down, it->subtree_nr + 1, it->subtree_alloc); |
| 94 | it->subtree_nr++; |
| 95 | |
| 96 | FLEX_ALLOC_MEM(down, name, path, pathlen); |
| 97 | down->cache_tree = NULL; |
| 98 | down->namelen = pathlen; |
| 99 | |
| 100 | if (pos < it->subtree_nr) |
| 101 | MOVE_ARRAY(it->down + pos + 1, it->down + pos, |
| 102 | it->subtree_nr - pos - 1); |
| 103 | it->down[pos] = down; |
| 104 | return down; |
| 105 | } |
| 106 | |
| 107 | struct cache_tree_sub *cache_tree_sub(struct cache_tree *it, const char *path) |
| 108 | { |
no test coverage detected