Fix linker error for internal functions
parent
33fdb0183a
commit
30b4daff22
|
@ -136,14 +136,6 @@ YDB_Error ydb_delete_current_page(YDB_Engine* instance);
|
||||||
|
|
||||||
// TODO: rebuild page offsets, etc.
|
// TODO: rebuild page offsets, etc.
|
||||||
|
|
||||||
// Internal usage only!
|
|
||||||
// Its only purpose to read current page data and set next_page offset.
|
|
||||||
// You should write prev_page offset on your own.
|
|
||||||
YDB_Error __ydb_read_page(YDB_Engine *inst);
|
|
||||||
// Moves file position to allocated block.
|
|
||||||
// Also changes last_free_page_offset.
|
|
||||||
YDB_Offset __ydb_allocate_page_and_seek(YDB_Engine *inst);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mainpage YeltsinDB docs index page
|
* @mainpage YeltsinDB docs index page
|
||||||
*
|
*
|
||||||
|
|
21
src/ydb.c
21
src/ydb.c
|
@ -52,7 +52,7 @@ void ydb_terminate_instance(YDB_Engine *instance) {
|
||||||
// Internal usage only!
|
// Internal usage only!
|
||||||
// Its only purpose to read current page data and set next_page offset.
|
// Its only purpose to read current page data and set next_page offset.
|
||||||
// You should write prev_page offset on your own.
|
// You should write prev_page offset on your own.
|
||||||
YDB_Error __ydb_read_page(YDB_Engine *inst) {
|
static YDB_Error __ydb_read_page(YDB_Engine *inst) {
|
||||||
THROW_IF_NULL(inst, YDB_ERR_INSTANCE_NOT_INITIALIZED);
|
THROW_IF_NULL(inst, YDB_ERR_INSTANCE_NOT_INITIALIZED);
|
||||||
|
|
||||||
fseek(inst->fd, inst->curr_page_offset, SEEK_SET);
|
fseek(inst->fd, inst->curr_page_offset, SEEK_SET);
|
||||||
|
@ -88,7 +88,7 @@ YDB_Error __ydb_read_page(YDB_Engine *inst) {
|
||||||
}
|
}
|
||||||
// Moves file position to allocated block.
|
// Moves file position to allocated block.
|
||||||
// Also changes last_free_page_offset.
|
// Also changes last_free_page_offset.
|
||||||
YDB_Offset __ydb_allocate_page_and_seek(YDB_Engine *inst) {
|
static YDB_Offset __ydb_allocate_page_and_seek(YDB_Engine *inst) {
|
||||||
YDB_Offset result = 0;
|
YDB_Offset result = 0;
|
||||||
// If no free pages in the table, then...
|
// If no free pages in the table, then...
|
||||||
if (inst->last_free_page_offset == 0) {
|
if (inst->last_free_page_offset == 0) {
|
||||||
|
@ -149,7 +149,7 @@ YDB_Error ydb_load_table(YDB_Engine *instance, const char *path) {
|
||||||
|
|
||||||
char signature[4];
|
char signature[4];
|
||||||
fread(signature, 1, 4, instance->fd);
|
fread(signature, 1, 4, instance->fd);
|
||||||
int signature_match = memcmp(signature, YDB_TABLE_FILE_SIGN, 4) == 0;
|
int signature_match = memcmp(signature, YDB_TABLE_FILE_SIGN, 3) == 0;
|
||||||
if (!signature_match) {
|
if (!signature_match) {
|
||||||
return YDB_ERR_TABLE_DATA_CORRUPTED;
|
return YDB_ERR_TABLE_DATA_CORRUPTED;
|
||||||
}
|
}
|
||||||
|
@ -161,6 +161,19 @@ YDB_Error ydb_load_table(YDB_Engine *instance, const char *path) {
|
||||||
return YDB_ERR_TABLE_DATA_VERSION_MISMATCH;
|
return YDB_ERR_TABLE_DATA_VERSION_MISMATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (signature[3]) {
|
||||||
|
case '!':
|
||||||
|
break;
|
||||||
|
case '?':
|
||||||
|
if (instance->ver_minor < 2) {
|
||||||
|
return YDB_ERR_TABLE_DATA_CORRUPTED;
|
||||||
|
}
|
||||||
|
// TODO mark table as possibly corrupted and start rollback from journal
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return YDB_ERR_TABLE_DATA_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
fread(&(instance->first_page_offset), sizeof(YDB_Offset), 1, instance->fd);
|
fread(&(instance->first_page_offset), sizeof(YDB_Offset), 1, instance->fd);
|
||||||
fread(&(instance->last_page_offset), sizeof(YDB_Offset), 1, instance->fd);
|
fread(&(instance->last_page_offset), sizeof(YDB_Offset), 1, instance->fd);
|
||||||
fread(&(instance->last_free_page_offset), sizeof(YDB_Offset), 1, instance->fd);
|
fread(&(instance->last_free_page_offset), sizeof(YDB_Offset), 1, instance->fd);
|
||||||
|
@ -214,7 +227,7 @@ YDB_Error ydb_create_table(YDB_Engine *instance, const char *path) {
|
||||||
|
|
||||||
// TODO test on other byte ordered archs
|
// TODO test on other byte ordered archs
|
||||||
char tpl[] = YDB_TABLE_FILE_SIGN
|
char tpl[] = YDB_TABLE_FILE_SIGN
|
||||||
"\x00\x01"
|
"\x00\x02"
|
||||||
"\x1E\x00\x00\x00\x00\x00\x00\x00"
|
"\x1E\x00\x00\x00\x00\x00\x00\x00"
|
||||||
"\x1E\x00\x00\x00\x00\x00\x00\x00"
|
"\x1E\x00\x00\x00\x00\x00\x00\x00"
|
||||||
"\x00\x00\x00\x00\x00\x00\x00\x00";
|
"\x00\x00\x00\x00\x00\x00\x00\x00";
|
||||||
|
|
Loading…
Reference in New Issue