diff options
author | vapier <vapier@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-04-16 21:30:47 +0000 |
---|---|---|
committer | vapier <vapier@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-04-16 21:30:47 +0000 |
commit | 5a79a171328a9dd45496d0c287ce2bb53838f908 (patch) | |
tree | bf28d36028fc65a7e351050314a2053ce88284c7 /miscutils/less.c | |
parent | 875fbc641d215e961fc1cb83d17810ee64163659 (diff) | |
download | busybox-w32-5a79a171328a9dd45496d0c287ce2bb53838f908.tar.gz busybox-w32-5a79a171328a9dd45496d0c287ce2bb53838f908.tar.bz2 busybox-w32-5a79a171328a9dd45496d0c287ce2bb53838f908.zip |
use xmalloc, dont hardcode length of string, and get rid of pointless call to memset
git-svn-id: svn://busybox.net/trunk/busybox@14896 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'miscutils/less.c')
-rw-r--r-- | miscutils/less.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/miscutils/less.c b/miscutils/less.c index 6b0cab526..eba916a80 100644 --- a/miscutils/less.c +++ b/miscutils/less.c | |||
@@ -625,12 +625,11 @@ static char *process_regex_on_line(char *line, regex_t *pattern) | |||
625 | insert_highlights, and then the line is returned. */ | 625 | insert_highlights, and then the line is returned. */ |
626 | 626 | ||
627 | int match_status; | 627 | int match_status; |
628 | char *line2 = (char *) malloc((sizeof(char) * (strlen(line) + 1)) + 64); | 628 | char *line2 = (char *) xmalloc((sizeof(char) * (strlen(line) + 1)) + 64); |
629 | char sub_line[256]; | 629 | char sub_line[256]; |
630 | int prev_eo = 0; | 630 | int prev_eo = 0; |
631 | regmatch_t match_structs; | 631 | regmatch_t match_structs; |
632 | 632 | ||
633 | memset(sub_line, 0, 256); | ||
634 | strcpy(line2, line); | 633 | strcpy(line2, line); |
635 | 634 | ||
636 | match_found = 0; | 635 | match_found = 0; |
@@ -638,7 +637,7 @@ static char *process_regex_on_line(char *line, regex_t *pattern) | |||
638 | 637 | ||
639 | while (match_status == 0) { | 638 | while (match_status == 0) { |
640 | 639 | ||
641 | memset(sub_line, 0, 256); | 640 | memset(sub_line, 0, sizeof(sub_line)); |
642 | 641 | ||
643 | if (match_found == 0) | 642 | if (match_found == 0) |
644 | match_found = 1; | 643 | match_found = 1; |