*new* uncapped_alloc: print places where the user decides how much memory to alloc
[smatch.git] / smatch_db.c
blob23706a4b3f5d275a5f39aeca4138675e5d02901e
1 /*
2 * smatch/smatch_db.c
4 * Copyright (C) 2010 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
8 */
10 #include <string.h>
11 #include <sqlite3.h>
12 #include "smatch.h"
13 #include "smatch_extra.h"
15 static sqlite3 *db;
17 void sql_exec(int (*callback)(void*, int, char**, char**), const char *sql)
19 char *err = NULL;
20 int rc;
22 if (!db)
23 return;
25 rc = sqlite3_exec(db, sql, callback, 0, &err);
26 if (rc != SQLITE_OK) {
27 fprintf(stderr, "SQL error #2: %s\n", err);
28 exit(1);
32 void open_smatch_db(void)
34 int rc;
36 if (option_no_db)
37 return;
39 rc = sqlite3_open("smatch_db.sqlite", &db);
40 if (rc != SQLITE_OK)
41 option_no_db = 1;