1 /*	Copyright (C) 1995, 1996 Tom Lord
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU Library General Public License as published by
5  * the Free Software Foundation; either version 2, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU Library General Public License for more details.
12  *
13  * You should have received a copy of the GNU Library General Public License
14  * along with this software; see the file COPYING.  If not, write to
15  * the Free Software Foundation, 59 Temple Place - Suite 330,
16  * Boston, MA 02111-1307, USA.
17  */
18 
19 
20 
21 #include "rx.h"
22 #include "rxall.h"
23 #include "rxhash.h"
24 #include "rxnfa.h"
25 #include "rxsuper.h"
26 
27 
28 
29 const char rx_version_string[] = "GNU Rx version 1.5";
30 
31 
32 #ifdef __STDC__
33 struct rx *
rx_make_rx(int cset_size)34 rx_make_rx (int cset_size)
35 #else
36 struct rx *
37 rx_make_rx (cset_size)
38      int cset_size;
39 #endif
40 {
41   static int rx_id = 0;
42   struct rx * new_rx;
43   new_rx = (struct rx *)malloc (sizeof (*new_rx));
44   rx_bzero ((char *)new_rx, sizeof (*new_rx));
45   new_rx->rx_id = rx_id++;
46   new_rx->cache = rx_default_cache;
47   new_rx->local_cset_size = cset_size;
48   new_rx->instruction_table = rx_id_instruction_table;
49   new_rx->next_nfa_id = 0;
50   return new_rx;
51 }
52 
53 #ifdef __STDC__
54 void
rx_free_rx(struct rx * rx)55 rx_free_rx (struct rx * rx)
56 #else
57 void
58 rx_free_rx (rx)
59      struct rx * rx;
60 #endif
61 {
62   if (rx->start_set)
63     rx->start_set->starts_for = 0;
64   rx_free_nfa (rx);
65   free (rx);
66 }
67 
68 
69 #ifdef __STDC__
70 void
rx_bzero(char * mem,int size)71 rx_bzero (char * mem, int size)
72 #else
73 void
74 rx_bzero (mem, size)
75      char * mem;
76      int size;
77 #endif
78 {
79   while (size)
80     {
81       *mem = 0;
82       ++mem;
83       --size;
84     }
85 }
86