From 0a2e62f57734f820cd20e151d1150342408552ed Mon Sep 17 00:00:00 2001 From: gabrielgio Date: Sat, 17 Feb 2024 17:13:07 +0100 Subject: ref: Apply astyle --style=linux --- lib/data.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'lib/data.c') diff --git a/lib/data.c b/lib/data.c index 7ebf597..e94e0a7 100644 --- a/lib/data.c +++ b/lib/data.c @@ -8,7 +8,8 @@ const char *insert_into = "INSERT INTO words (LINE) VALUES($VVV);"; const char *select_words = "SELECT Id, Line FROM words WHERE line like $VVV LIMIT 10;"; const char *create_table = "CREATE TABLE IF NOT EXISTS words (ID INTEGER PRIMARY KEY AUTOINCREMENT, LINE TEXT NOT NULL);"; -Data* new_data(const char* con) { +Data* new_data(const char* con) +{ Data* data = (Data*)malloc(sizeof(Data)); int v = sqlite3_open(con, &(data->db)); @@ -27,13 +28,15 @@ Data* new_data(const char* con) { return data; } -void free_data(Data* data) { +void free_data(Data* data) +{ sqlite3_close(data->db); free(data); } -void insert(Data* data, char* line, int len) { - sqlite3_stmt *stmt; +void insert(Data* data, char* line, int len) +{ + sqlite3_stmt *stmt; int r = sqlite3_prepare_v2(data->db, insert_into, -1, &stmt, NULL); if (r != SQLITE_OK) { @@ -55,8 +58,9 @@ void insert(Data* data, char* line, int len) { sqlite3_finalize(stmt); } -void bootstrap(Data* data) { - sqlite3_stmt *stmt; +void bootstrap(Data* data) +{ + sqlite3_stmt *stmt; int r = sqlite3_prepare_v2(data->db, create_table, -1, &stmt, NULL); if (r != SQLITE_OK) { @@ -76,8 +80,9 @@ void bootstrap(Data* data) { sqlite3_finalize(stmt); } -LIST* data_select(Data* data, char *sch, int len) { - sqlite3_stmt *stmt; +LIST* data_select(Data* data, char *sch, int len) +{ + sqlite3_stmt *stmt; int r = sqlite3_prepare_v2(data->db, select_words, -1, &stmt, NULL); if (r != SQLITE_OK) { @@ -112,6 +117,7 @@ LIST* data_select(Data* data, char *sch, int len) { return list; } -void print_result_code(int code) { +void print_result_code(int code) +{ printf(sqlite3_errstr(code)); } -- cgit v1.2.3