aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2023-06-01 09:41:12 -0500
committerAnthony Wang2023-06-01 09:41:12 -0500
commit3f0388f34034d20b1650c58ded9bf8b8c28d13fd (patch)
tree6859b697466fc2f749bbca1f65299122dfa53f08
parent1db25e6c5463be869e755ccdf1ee83b1e0a087f9 (diff)
Remove unused header files, fix compiler warnings
-rw-r--r--sd.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/sd.c b/sd.c
index 5ea3298..7d00989 100644
--- a/sd.c
+++ b/sd.c
@@ -2,9 +2,7 @@
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <time.h>
-#include <unistd.h>
#include <getopt.h>
#include <sqlite3.h>
#include "segmenttree.h"
@@ -23,7 +21,7 @@ int main(int argc, char* argv[]) {
int c = getopt_long(argc, argv, "f:v", long_options, &option_index);
if (c == -1) break;
switch (c) {
- case 'f': file = strdup(optarg); break;
+ case 'f': file = optarg; break;
case 'v': verbose = true; break;
default: abort();
}
@@ -74,16 +72,12 @@ int main(int argc, char* argv[]) {
sqlite3_prepare_v3(db, "SELECT key, val FROM cards WHERE idx=?", -1, 0, &stmt, NULL);
sqlite3_bind_int(stmt, 1, i);
sqlite3_step(stmt);
- char *key, *val;
- key = strdup(sqlite3_column_text(stmt, 0));
- val = strdup(sqlite3_column_text(stmt, 1));
- sqlite3_finalize(stmt);
-
- printf("> %s\n", key);
+ printf("> %s\n", sqlite3_column_text(stmt, 0));
/* Wait for confirmation */
char b = getchar();
- printf("%s\n", val);
+ printf("%s\n", sqlite3_column_text(stmt, 1));
+ sqlite3_finalize(stmt);
/* Read user input */
b = getchar();