diff options
author | Rob Landley <rob@landley.net> | 2006-05-21 18:30:35 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-05-21 18:30:35 +0000 |
commit | 9ffd42317b5a53c2236268808e34c90601f286c1 (patch) | |
tree | b126ca6ff7d2db91fa3525c6e5d3978932137fa3 /editors | |
parent | c020f5f518714af603488c7d9e6cc72543fabc49 (diff) | |
download | busybox-w32-9ffd42317b5a53c2236268808e34c90601f286c1.tar.gz busybox-w32-9ffd42317b5a53c2236268808e34c90601f286c1.tar.bz2 busybox-w32-9ffd42317b5a53c2236268808e34c90601f286c1.zip |
Minor cleanups: Convert a few calloc() calls to xzalloc, remove unnecessary
memset, collate variable declarations...
Diffstat (limited to 'editors')
-rw-r--r-- | editors/awk.c | 16 | ||||
-rw-r--r-- | editors/sed.c | 4 |
2 files changed, 10 insertions, 10 deletions
diff --git a/editors/awk.c b/editors/awk.c index f4eb1ab90..74f9d8e54 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -474,9 +474,9 @@ static xhash *hash_init(void) | |||
474 | { | 474 | { |
475 | xhash *newhash; | 475 | xhash *newhash; |
476 | 476 | ||
477 | newhash = (xhash *)xcalloc(1, sizeof(xhash)); | 477 | newhash = (xhash *)xzalloc(sizeof(xhash)); |
478 | newhash->csize = FIRST_PRIME; | 478 | newhash->csize = FIRST_PRIME; |
479 | newhash->items = (hash_item **)xcalloc(newhash->csize, sizeof(hash_item *)); | 479 | newhash->items = (hash_item **)xzalloc(newhash->csize * sizeof(hash_item *)); |
480 | 480 | ||
481 | return newhash; | 481 | return newhash; |
482 | } | 482 | } |
@@ -505,7 +505,7 @@ static void hash_rebuild(xhash *hash) | |||
505 | return; | 505 | return; |
506 | 506 | ||
507 | newsize = PRIMES[hash->nprime++]; | 507 | newsize = PRIMES[hash->nprime++]; |
508 | newitems = (hash_item **)xcalloc(newsize, sizeof(hash_item *)); | 508 | newitems = (hash_item **)xzalloc(newsize * sizeof(hash_item *)); |
509 | 509 | ||
510 | for (i=0; i<hash->csize; i++) { | 510 | for (i=0; i<hash->csize; i++) { |
511 | hi = hash->items[i]; | 511 | hi = hash->items[i]; |
@@ -536,7 +536,7 @@ static void *hash_find(xhash *hash, const char *name) | |||
536 | hash_rebuild(hash); | 536 | hash_rebuild(hash); |
537 | 537 | ||
538 | l = strlen(name) + 1; | 538 | l = strlen(name) + 1; |
539 | hi = xcalloc(sizeof(hash_item) + l, 1); | 539 | hi = xzalloc(sizeof(hash_item) + l); |
540 | memcpy(hi->name, name, l); | 540 | memcpy(hi->name, name, l); |
541 | 541 | ||
542 | idx = hashidx(name) % hash->csize; | 542 | idx = hashidx(name) % hash->csize; |
@@ -993,7 +993,7 @@ static node *new_node(uint32_t info) | |||
993 | { | 993 | { |
994 | register node *n; | 994 | register node *n; |
995 | 995 | ||
996 | n = (node *)xcalloc(sizeof(node), 1); | 996 | n = (node *)xzalloc(sizeof(node)); |
997 | n->info = info; | 997 | n->info = info; |
998 | n->lineno = lineno; | 998 | n->lineno = lineno; |
999 | return n; | 999 | return n; |
@@ -1095,7 +1095,7 @@ static node *parse_expr(uint32_t iexp) | |||
1095 | case TC_NUMBER: | 1095 | case TC_NUMBER: |
1096 | case TC_STRING: | 1096 | case TC_STRING: |
1097 | cn->info = OC_VAR; | 1097 | cn->info = OC_VAR; |
1098 | v = cn->l.v = xcalloc(sizeof(var), 1); | 1098 | v = cn->l.v = xzalloc(sizeof(var)); |
1099 | if (tc & TC_NUMBER) | 1099 | if (tc & TC_NUMBER) |
1100 | setvar_i(v, t.number); | 1100 | setvar_i(v, t.number); |
1101 | else | 1101 | else |
@@ -1104,7 +1104,7 @@ static node *parse_expr(uint32_t iexp) | |||
1104 | 1104 | ||
1105 | case TC_REGEXP: | 1105 | case TC_REGEXP: |
1106 | mk_re_node(t.string, cn, | 1106 | mk_re_node(t.string, cn, |
1107 | (regex_t *)xcalloc(sizeof(regex_t),2)); | 1107 | (regex_t *)xzalloc(sizeof(regex_t)*2)); |
1108 | break; | 1108 | break; |
1109 | 1109 | ||
1110 | case TC_FUNCTION: | 1110 | case TC_FUNCTION: |
@@ -1590,7 +1590,7 @@ static void hashwalk_init(var *v, xhash *array) | |||
1590 | free(v->x.walker); | 1590 | free(v->x.walker); |
1591 | 1591 | ||
1592 | v->type |= VF_WALK; | 1592 | v->type |= VF_WALK; |
1593 | w = v->x.walker = (char **)xcalloc(2 + 2*sizeof(char *) + array->glen, 1); | 1593 | w = v->x.walker = (char **)xzalloc(2 + 2*sizeof(char *) + array->glen); |
1594 | *w = *(w+1) = (char *)(w + 2); | 1594 | *w = *(w+1) = (char *)(w + 2); |
1595 | for (i=0; i<array->csize; i++) { | 1595 | for (i=0; i<array->csize; i++) { |
1596 | hi = array->items[i]; | 1596 | hi = array->items[i]; |
diff --git a/editors/sed.c b/editors/sed.c index 893931153..39b28d006 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -449,7 +449,7 @@ static char *parse_cmd_args(sed_cmd_t *sed_cmd, char *cmdstr) | |||
449 | parse_escapes(match,match,strlen(match),i,i); | 449 | parse_escapes(match,match,strlen(match),i,i); |
450 | parse_escapes(replace,replace,strlen(replace),i,i); | 450 | parse_escapes(replace,replace,strlen(replace),i,i); |
451 | 451 | ||
452 | sed_cmd->string = xcalloc(1, (strlen(match) + 1) * 2); | 452 | sed_cmd->string = xzalloc((strlen(match) + 1) * 2); |
453 | for (i = 0; match[i] && replace[i]; i++) { | 453 | for (i = 0; match[i] && replace[i]; i++) { |
454 | sed_cmd->string[i * 2] = match[i]; | 454 | sed_cmd->string[i * 2] = match[i]; |
455 | sed_cmd->string[(i * 2) + 1] = replace[i]; | 455 | sed_cmd->string[(i * 2) + 1] = replace[i]; |
@@ -513,7 +513,7 @@ static void add_cmd(char *cmdstr) | |||
513 | * part1 part2 part3 | 513 | * part1 part2 part3 |
514 | */ | 514 | */ |
515 | 515 | ||
516 | sed_cmd = xcalloc(1, sizeof(sed_cmd_t)); | 516 | sed_cmd = xzalloc(sizeof(sed_cmd_t)); |
517 | 517 | ||
518 | /* first part (if present) is an address: either a '$', a number or a /regex/ */ | 518 | /* first part (if present) is an address: either a '$', a number or a /regex/ */ |
519 | cmdstr += get_address(cmdstr, &sed_cmd->beg_line, &sed_cmd->beg_match); | 519 | cmdstr += get_address(cmdstr, &sed_cmd->beg_line, &sed_cmd->beg_match); |