diff options
| author | Jan200101 <sentrycraft123@gmail.com> | 2025-06-26 10:22:50 +0200 |
|---|---|---|
| committer | Jan200101 <sentrycraft123@gmail.com> | 2025-06-26 10:22:50 +0200 |
| commit | d073a3b9b1d4d070b0f58e962a90396d67003930 (patch) | |
| tree | cd07b30b7226afad1fbcb00e111ca14d862004c5 /loggerDB | |
| parent | 6487d89461e47f8fab056b4a7228864dc208c4fb (diff) | |
| download | loggerdb-master.tar.gz loggerdb-master.zip | |
Diffstat (limited to 'loggerDB')
| -rw-r--r-- | loggerDB/bench/naive.c | 1 | ||||
| -rw-r--r-- | loggerDB/bench/read-write.c | 1 | ||||
| -rw-r--r-- | loggerDB/bench/simple.c | 1 | ||||
| -rw-r--r-- | loggerDB/bench/stream.c | 1 | ||||
| -rw-r--r-- | loggerDB/include/loggerDB/table.h | 4 | ||||
| -rw-r--r-- | loggerDB/src/table.c | 9 |
6 files changed, 17 insertions, 0 deletions
diff --git a/loggerDB/bench/naive.c b/loggerDB/bench/naive.c index 6e063a8..157da53 100644 --- a/loggerDB/bench/naive.c +++ b/loggerDB/bench/naive.c @@ -28,6 +28,7 @@ int main() res = ldb_table_open(&db, TABLE_NAME, &table); assert(res == LOGGERDB_OK); + assert(ldb_table_valid(&table) == LOGGERDB_OK); time_t t = 0; time_t max_t = ((time_t)BENCH_TIME); diff --git a/loggerDB/bench/read-write.c b/loggerDB/bench/read-write.c index 665797e..12a67ec 100644 --- a/loggerDB/bench/read-write.c +++ b/loggerDB/bench/read-write.c @@ -36,6 +36,7 @@ int main() res = ldb_table_open(&db, TABLE_NAME, &table); assert(res == LOGGERDB_OK); + assert(ldb_table_valid(&table) == LOGGERDB_OK); fprintf(stderr, "Storing test data..."); t = EPOCH_DAYS(3); diff --git a/loggerDB/bench/simple.c b/loggerDB/bench/simple.c index 55ab9ec..9e067fe 100644 --- a/loggerDB/bench/simple.c +++ b/loggerDB/bench/simple.c @@ -26,6 +26,7 @@ int main() res = ldb_table_open(&db, TABLE_NAME, &table); assert(res == LOGGERDB_OK); + assert(ldb_table_valid(&table) == LOGGERDB_OK); time_t t = 0; time_t max_t = ((time_t)BENCH_TIME); diff --git a/loggerDB/bench/stream.c b/loggerDB/bench/stream.c index 8213ef8..4990f29 100644 --- a/loggerDB/bench/stream.c +++ b/loggerDB/bench/stream.c @@ -28,6 +28,7 @@ int main() res = ldb_table_open(&db, TABLE_NAME, &table); assert(res == LOGGERDB_OK); + assert(ldb_table_valid(&table) == LOGGERDB_OK); time_t t = 0; time_t max_t = ((time_t)BENCH_TIME); diff --git a/loggerDB/include/loggerDB/table.h b/loggerDB/include/loggerDB/table.h index 9bdbb65..00bc492 100644 --- a/loggerDB/include/loggerDB/table.h +++ b/loggerDB/include/loggerDB/table.h @@ -1,14 +1,18 @@ #ifndef LOGGERDB_TABLE_H #define LOGGERDB_TABLE_H +#include <stdint.h> + typedef struct loggerdb loggerdb; typedef struct loggerdb_table { char* path; loggerdb* db; + uint8_t init; } loggerdb_table; int ldb_table_open(loggerdb* db, const char* name, loggerdb_table* table); int ldb_table_close(loggerdb_table* table); +int ldb_table_valid(loggerdb_table* table); #endif
\ No newline at end of file diff --git a/loggerDB/src/table.c b/loggerDB/src/table.c index f2d184a..b1ab4fc 100644 --- a/loggerDB/src/table.c +++ b/loggerDB/src/table.c @@ -24,6 +24,7 @@ int ldb_table_open(loggerdb* db, const char* name, loggerdb_table* table) table->path = table_path; table->db = db; + table->init = 1; return LOGGERDB_OK; } @@ -36,7 +37,15 @@ int ldb_table_close(loggerdb_table* table) free(table->path); table->path = NULL; table->db = NULL; + table->init = 0; return LOGGERDB_OK; } +int ldb_table_valid(loggerdb_table* table) +{ + if (!table || !table->init || !table->path) + return LOGGERDB_INVALID; + + return LOGGERDB_OK; +} |
