Write an empty index leaf page.
| 1241 | |
| 1242 | // Write an empty index leaf page. |
| 1243 | static uint32_t write_empty_index_leaf(FILE *fp, uint32_t *next_page) { |
| 1244 | *next_page = cbm_skip_pending_byte(*next_page); |
| 1245 | uint32_t pnum = (*next_page)++; |
| 1246 | uint8_t page[CBM_PAGE_SIZE]; |
| 1247 | memset(page, 0, CBM_PAGE_SIZE); |
| 1248 | page[0] = NEWLINE_BYTE; |
| 1249 | put_u16(page + HDR_FREEBLOCK_OFF, 0); |
| 1250 | put_u16(page + HDR_CELLCOUNT_OFF, 0); |
| 1251 | put_u16(page + HDR_CONTENT_OFF, (uint16_t)CBM_PAGE_SIZE); |
| 1252 | page[HDR_FRAGBYTES_OFF] = 0; |
| 1253 | (void)fseek(fp, (long)(pnum - SKIP_ONE) * CBM_PAGE_SIZE, SEEK_SET); |
| 1254 | (void)fwrite(page, SKIP_ONE, CBM_PAGE_SIZE, fp); |
| 1255 | return pnum; |
| 1256 | } |
| 1257 | |
| 1258 | // Write leaf pages for an index, returns root page. |
| 1259 | static uint32_t write_index_btree(FILE *fp, uint32_t *next_page, uint8_t **cells, int *cell_lens, |
no test coverage detected