Skip to content

Commit 66c338e

Browse files
committed
Remove unnecessary memory allocation
1 parent 5729ae0 commit 66c338e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/utils/acmp.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,15 +387,15 @@ if (parser->is_active != 0) return -1;
387387
child->pattern = (char *)"";
388388
child->letter = letter;
389389
child->depth = i;
390-
child->text = (char *)calloc(1, length + 2);
390+
child->text = (char *)calloc(1, i + 2);
391391
/* ENH: Check alloc succeded */
392392
for (j = 0; j <= i; j++) child->text[j] = pattern[j];
393393
}
394394
if (i == length - 1) {
395395
if (child->is_last == 0) {
396396
parser->dict_count++;
397397
child->is_last = 1;
398-
child->pattern = (char *)calloc(1, length + 2);
398+
child->pattern = (char *)calloc(1, length + 1);
399399
/* ENH: Check alloc succeded */
400400
memcpy(child->pattern, pattern, length);
401401
child->pattern[length] = '\0';

0 commit comments

Comments
 (0)