Added some debugging
[cascardo/grammar.git] / scanner.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <scanner.h>
4
5 static void string_free (gpointer data)
6 {
7   g_string_free ((GString*) data, TRUE);
8 }
9
10 scanner_t* scanner_new (readcb cb, gpointer data)
11 {
12
13   scanner_t* scanner;
14
15   scanner = g_malloc (sizeof (scanner_t));
16   scanner->cb = cb;
17   scanner->data = data;
18   scanner->buffer = g_string_sized_new (256);
19   scanner->reserved = g_hash_table_new_full (g_string_hash, g_string_equal,
20                                              string_free, NULL);
21
22   return scanner;
23
24 }
25
26 void scanner_delete (scanner_t* scanner)
27 {
28   g_hash_table_destroy (scanner->reserved);
29   g_string_free (scanner->buffer, TRUE);
30   g_free (scanner);
31 }