git-svn: trunk@3067
Tomasz Kojm authored on 2007/05/26 23:08:18... | ... |
@@ -38,7 +38,7 @@ |
38 | 38 |
|
39 | 39 |
int cli_ac_addpatt(struct cli_matcher *root, struct cli_ac_patt *pattern) |
40 | 40 |
{ |
41 |
- struct cli_ac_node *pt, *next; |
|
41 |
+ struct cli_ac_node *pt, *next, **newtable; |
|
42 | 42 |
uint8_t i; |
43 | 43 |
uint16_t len = MIN(root->ac_maxdepth, pattern->length); |
44 | 44 |
|
... | ... |
@@ -85,15 +85,17 @@ int cli_ac_addpatt(struct cli_matcher *root, struct cli_ac_patt *pattern) |
85 | 85 |
} |
86 | 86 |
|
87 | 87 |
root->ac_nodes++; |
88 |
- root->ac_nodetable = (struct cli_ac_node **) cli_realloc2(root->ac_nodetable, root->ac_nodes * sizeof(struct cli_ac_node *)); |
|
89 |
- if(!root->ac_nodetable) { |
|
88 |
+ newtable = (struct cli_ac_node **) cli_realloc(root->ac_nodetable, root->ac_nodes * sizeof(struct cli_ac_node *)); |
|
89 |
+ if(!newtable) { |
|
90 |
+ root->ac_nodes--; |
|
90 | 91 |
cli_errmsg("cli_ac_addpatt: Can't realloc ac_nodetable\n"); |
91 | 92 |
if(next->trans) |
92 | 93 |
free(next->trans); |
93 | 94 |
free(next); |
94 | 95 |
return CL_EMEM; |
95 | 96 |
} |
96 |
- root->ac_nodetable[root->ac_nodes - 1] = next; |
|
97 |
+ newtable[root->ac_nodes - 1] = next; |
|
98 |
+ root->ac_nodetable = newtable; |
|
97 | 99 |
|
98 | 100 |
pt->trans[(unsigned char) (pattern->pattern[i] & 0xff)] = next; |
99 | 101 |
pt->leaf = 0; |