Ensure leaves array has capacity for one more entry. Returns false on allocation failure.
| 1073 | // Ensure leaves array has capacity for one more entry. |
| 1074 | // Returns false on allocation failure. |
| 1075 | static bool pb_ensure_leaf_cap(PageBuilder *pb) { |
| 1076 | if (pb->leaf_count < pb->leaf_cap) { |
| 1077 | return true; |
| 1078 | } |
| 1079 | pb->leaf_cap = pb->leaf_cap == 0 ? INITIAL_LEAF_CAP : pb->leaf_cap * GROWTH_FACTOR; |
| 1080 | void *tmp = realloc(pb->leaves, (size_t)pb->leaf_cap * sizeof(PageRef)); |
| 1081 | if (!tmp) { |
| 1082 | /* Same consistent-empty contract as pb_flush_leaf's growth path. */ |
| 1083 | free(pb->leaves); |
| 1084 | pb->leaves = NULL; |
| 1085 | pb->leaf_count = 0; |
| 1086 | pb->leaf_cap = 0; |
| 1087 | return false; |
| 1088 | } |
| 1089 | pb->leaves = (PageRef *)tmp; |
| 1090 | return true; |
| 1091 | } |
| 1092 | |
| 1093 | // SQLite overflow thresholds for leaf table B-tree pages (PAGE_SIZE=65536, reserved=0): |
| 1094 | // usable = PAGE_SIZE = 65536 |
no outgoing calls
no test coverage detected