- if(sqlitestep(s) != SQLITE_ROW) {
- Error("sqlite", ERR_ERROR, "Error getting row count for %s.", tablename);
- sqlite3_finalize(s);
+ /* the handlers do all the checking and cleanup */
+ if(t->init)
+ (t->init)(NULL, t->tag);
+
+ (t->data)(c, t->tag);
+
+ if(t->fini)
+ (t->fini)(NULL, t->tag);
+
+ nsfree(POOL_SQLITE, t);
+}
+
+static void loadtablecount(SQLiteConn *c, void *tag) {
+ struct sqlitetableloader *t = (struct sqlitetableloader *)tag;
+ SQLiteResult *r = NULL;
+
+ if(!c) { /* unloaded */
+ nsfree(POOL_SQLITE, t);
+ return;
+ }
+
+ if(!(r = sqlitegetresult(c)) || !sqlitefetchrow(r)) {
+ Error("sqlite", ERR_ERROR, "Error getting row count for %s.", t->tablename);
+ nsfree(POOL_SQLITE, t);
+
+ if(r)
+ sqliteclear(r);