Check a tree and its subtrees. */
| 3294 | |
| 3295 | /* Check a tree and its subtrees. */ |
| 3296 | static void do_check_tree(mstate m, tchunkptr t) { |
| 3297 | tchunkptr head = 0; |
| 3298 | tchunkptr u = t; |
| 3299 | bindex_t tindex = t->index; |
| 3300 | size_t tsize = chunksize(t); |
| 3301 | bindex_t idx; |
| 3302 | compute_tree_index(tsize, idx); |
| 3303 | assert(tindex == idx); |
| 3304 | assert(tsize >= MIN_LARGE_SIZE); |
| 3305 | assert(tsize >= minsize_for_tree_index(idx)); |
| 3306 | assert((idx == NTREEBINS-1) || (tsize < minsize_for_tree_index((idx+1)))); |
| 3307 | |
| 3308 | do { /* traverse through chain of same-sized nodes */ |
| 3309 | do_check_any_chunk(m, ((mchunkptr)u)); |
| 3310 | assert(u->index == tindex); |
| 3311 | assert(chunksize(u) == tsize); |
| 3312 | assert(!is_inuse(u)); |
| 3313 | assert(!next_pinuse(u)); |
| 3314 | assert(u->fd->bk == u); |
| 3315 | assert(u->bk->fd == u); |
| 3316 | if (u->parent == 0) { |
| 3317 | assert(u->child[0] == 0); |
| 3318 | assert(u->child[1] == 0); |
| 3319 | } |
| 3320 | else { |
| 3321 | assert(head == 0); /* only one node on chain has parent */ |
| 3322 | head = u; |
| 3323 | assert(u->parent != u); |
| 3324 | assert (u->parent->child[0] == u || |
| 3325 | u->parent->child[1] == u || |
| 3326 | *((tbinptr*)(u->parent)) == u); |
| 3327 | if (u->child[0] != 0) { |
| 3328 | assert(u->child[0]->parent == u); |
| 3329 | assert(u->child[0] != u); |
| 3330 | do_check_tree(m, u->child[0]); |
| 3331 | } |
| 3332 | if (u->child[1] != 0) { |
| 3333 | assert(u->child[1]->parent == u); |
| 3334 | assert(u->child[1] != u); |
| 3335 | do_check_tree(m, u->child[1]); |
| 3336 | } |
| 3337 | if (u->child[0] != 0 && u->child[1] != 0) { |
| 3338 | assert(chunksize(u->child[0]) < chunksize(u->child[1])); |
| 3339 | } |
| 3340 | } |
| 3341 | u = u->fd; |
| 3342 | } while (u != t); |
| 3343 | assert(head != 0); |
| 3344 | } |
| 3345 | |
| 3346 | /* Check all the chunks in a treebin. */ |
| 3347 | static void do_check_treebin(mstate m, bindex_t i) { |
no test coverage detected