1
0
mirror of https://github.com/fumiama/fumidb.git synced 2026-06-10 21:24:12 +08:00

优化内存分配

This commit is contained in:
源文雨
2022-05-02 12:36:56 +08:00
parent 0196070fe0
commit e24f761f34
9 changed files with 129 additions and 105 deletions

View File

@@ -13,12 +13,7 @@ int init_file_header_page(int fd) {
lseek(fd, 0, SEEK_SET);
if(write(fd, header, PAGESZ) != PAGESZ) return 1;
// 将头的 HEADERSZ 字节之后的空间纳入空闲块
if(lseek(fd, 8, SEEK_SET) < 0) return EOF;
putle64(buf, HEADERSZ);
if(write(fd, buf, 8) != 8) return 1;
if(lseek(fd, HEADERSZ+8, SEEK_SET) < 0) return EOF;
putle16(buf, PAGESZ - HEADERSZ);
return write(fd, buf, 2) != 2;
return add_block(fd, PAGESZ-HEADERSZ, HEADERSZ);
}
uint16_t get_db_version(int fd) {