Clean up. Freeing the sm_states.
[smatch.git] / smatch.c
blob2813523e92e1b02ef381f998bc12de86d3851ac8
1 /*
2 * sparse/smatch.c
4 * Copyright (C) 2006 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
8 */
10 #include <stdio.h>
11 #include "smatch.h"
13 typedef void (*reg_func) (int id);
14 void register_derefed_params(int id);
15 void register_null_deref(int id);
16 void register_smatch_extra(int id);
17 void register_smatch_ignore(int id);
18 void register_overflow(int id);
19 void register_locking(int id);
20 void register_memory(int id);
21 void register_implications(int id);
22 /* <- your test goes here */
23 /* void register_template(int id); */
25 const reg_func reg_funcs[] = {
26 &register_smatch_extra, /* smatch_extra always has to be first */
27 &register_smatch_ignore,
28 &register_null_deref,
29 &register_overflow,
30 &register_locking,
31 &register_memory,
33 /* <- your test goes here */
34 /* &register_template, */
36 &register_implications, /* implications always has to be last */
37 NULL
40 void help()
42 printf("Usage: smatch [--debug][--debug-implied][sparse arguments]"
43 " file.c\n");
44 exit(1);
47 int main(int argc, char **argv)
49 int i;
50 reg_func func;
52 /* The script IDs start at 1.
53 0 is used for internal stuff. */
54 for(i = 0; (func = reg_funcs[i]); i++){
55 func(i + 1);
58 while(argc >= 2) {
59 if (!strcmp(argv[1], "--debug")) {
60 debug_states = 1;
61 } else if (!strcmp(argv[1], "--debug-implied")) {
62 debug_implied_states = 1;
63 } else if (!strcmp(argv[1], "--help")) {
64 help();
65 } else {
66 break;
68 argc--;
69 argv++;
72 smatch(argc, argv);
73 return 0;