Allocate and initialize a keyword set object, returning an opaque pointer to it. Return NULL if memory is not available. */
| 128 | /* Allocate and initialize a keyword set object, returning an opaque |
| 129 | pointer to it. Return NULL if memory is not available. */ |
| 130 | kwset_t |
| 131 | kwsalloc (unsigned char const *trans) |
| 132 | { |
| 133 | struct kwset *kwset; |
| 134 | |
| 135 | kwset = (struct kwset *) xmalloc(sizeof (struct kwset)); |
| 136 | |
| 137 | obstack_init(&kwset->obstack); |
| 138 | kwset->words = 0; |
| 139 | kwset->trie |
| 140 | = (struct trie *) obstack_alloc(&kwset->obstack, sizeof (struct trie)); |
| 141 | if (!kwset->trie) |
| 142 | { |
| 143 | kwsfree((kwset_t) kwset); |
| 144 | return NULL; |
| 145 | } |
| 146 | kwset->trie->accepting = 0; |
| 147 | kwset->trie->links = NULL; |
| 148 | kwset->trie->parent = NULL; |
| 149 | kwset->trie->next = NULL; |
| 150 | kwset->trie->fail = NULL; |
| 151 | kwset->trie->depth = 0; |
| 152 | kwset->trie->shift = 0; |
| 153 | kwset->mind = INT_MAX; |
| 154 | kwset->maxd = -1; |
| 155 | kwset->target = NULL; |
| 156 | kwset->trans = trans; |
| 157 | |
| 158 | return (kwset_t) kwset; |
| 159 | } |
| 160 | |
| 161 | /* This upper bound is valid for CHAR_BIT >= 4 and |
| 162 | exact for CHAR_BIT in { 4..11, 13, 15, 17, 19 }. */ |
no test coverage detected