Ensure leaves array has capacity for one more entry. Returns false on allocation failure.
| 1051 | // Ensure leaves array has capacity for one more entry. |
| 1052 | // Returns false on allocation failure. |
| 1053 | static bool pb_ensure_leaf_cap(PageBuilder *pb) { |
| 1054 | if (pb->leaf_count < pb->leaf_cap) { |
| 1055 | return true; |
| 1056 | } |
| 1057 | pb->leaf_cap = pb->leaf_cap == 0 ? INITIAL_LEAF_CAP : pb->leaf_cap * GROWTH_FACTOR; |
| 1058 | void *tmp = realloc(pb->leaves, (size_t)pb->leaf_cap * sizeof(PageRef)); |
| 1059 | if (!tmp) { |
| 1060 | /* Same consistent-empty contract as pb_flush_leaf's growth path. */ |
| 1061 | free(pb->leaves); |
| 1062 | pb->leaves = NULL; |
| 1063 | pb->leaf_count = 0; |
| 1064 | pb->leaf_cap = 0; |
| 1065 | return false; |
| 1066 | } |
| 1067 | pb->leaves = (PageRef *)tmp; |
| 1068 | return true; |
| 1069 | } |
| 1070 | |
| 1071 | // SQLite overflow thresholds for leaf table B-tree pages (PAGE_SIZE=65536, reserved=0): |
| 1072 | // usable = PAGE_SIZE = 65536 |
no outgoing calls
no test coverage detected