| 420 | } |
| 421 | |
| 422 | static int treeNodeTrim( treeNodeObj *node ) |
| 423 | { |
| 424 | int i; |
| 425 | |
| 426 | /* -------------------------------------------------------------------- */ |
| 427 | /* Trim subtrees, and free subnodes that come back empty. */ |
| 428 | /* -------------------------------------------------------------------- */ |
| 429 | for(i=0; i<node->numsubnodes; i++ ) { |
| 430 | if(treeNodeTrim(node->subnode[i])) { |
| 431 | destroyTreeNode(node->subnode[i]); |
| 432 | node->subnode[i] = node->subnode[node->numsubnodes-1]; |
| 433 | node->numsubnodes--; |
| 434 | i--; /* process the new occupant of this subnode entry */ |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | if( node->numsubnodes == 1 && node->numshapes == 0 ) { |
| 439 | node = node->subnode[0]; |
| 440 | } |
| 441 | /* if I only have 1 subnode promote that subnode to my positon */ |
| 442 | |
| 443 | /* -------------------------------------------------------------------- */ |
| 444 | /* We should be trimmed if we have no subnodes, and no shapes. */ |
| 445 | /* -------------------------------------------------------------------- */ |
| 446 | |
| 447 | return(node->numsubnodes == 0 && node->numshapes == 0); |
| 448 | } |
| 449 | |
| 450 | void msTreeTrim(treeObj *tree) |
| 451 | { |
no test coverage detected