summaryrefslogtreecommitdiff
path: root/editors/sed.c
diff options
context:
space:
mode:
authorGlenn L McGrath2003-03-28 04:23:23 +0000
committerGlenn L McGrath2003-03-28 04:23:23 +0000
commit56c633c1396aa8c11b92702041439fa1041fe7bb (patch)
tree9a62f20540beb0736a02235f2e737e49895f49a8 /editors/sed.c
parentc949bfa555cb844bd867b7c9fdf1874647df3543 (diff)
downloadbusybox-56c633c1396aa8c11b92702041439fa1041fe7bb.zip
busybox-56c633c1396aa8c11b92702041439fa1041fe7bb.tar.gz
make sed cleanup use linked list
Diffstat (limited to 'editors/sed.c')
-rw-r--r--editors/sed.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/editors/sed.c b/editors/sed.c
index 85eb9f6..037d2a8 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -118,30 +118,27 @@ const char * const semicolon_whitespace = "; \n\r\t\v\0";
#ifdef CONFIG_FEATURE_CLEAN_UP
static void destroy_cmd_strs(void)
{
- if (sed_cmds == NULL)
- return;
+ sed_cmd_t *sed_cmd = sed_cmd_head.linear;
- /* destroy all the elements in the array */
- while (--ncmds >= 0) {
+ while (sed_cmd) {
+ sed_cmd_t *sed_cmd_next = sed_cmd->linear;
- if (sed_cmds[ncmds]->beg_match) {
- regfree(sed_cmds[ncmds]->beg_match);
- free(sed_cmds[ncmds]->beg_match);
+ if (sed_cmd->beg_match) {
+ regfree(sed_cmd->beg_match);
+ free(sed_cmd->beg_match);
}
- if (sed_cmds[ncmds]->end_match) {
- regfree(sed_cmds[ncmds]->end_match);
- free(sed_cmds[ncmds]->end_match);
+ if (sed_cmd->end_match) {
+ regfree(sed_cmd->end_match);
+ free(sed_cmd->end_match);
}
- if (sed_cmds[ncmds]->sub_match) {
- regfree(sed_cmds[ncmds]->sub_match);
- free(sed_cmds[ncmds]->sub_match);
+ if (sed_cmd->sub_match) {
+ regfree(sed_cmd->sub_match);
+ free(sed_cmd->sub_match);
}
- free(sed_cmds[ncmds]->replace);
+ free(sed_cmd->replace);
+ free(sed_cmd);
+ sed_cmd = sed_cmd_next;
}
-
- /* destroy the array */
- free(sed_cmds);
- sed_cmds = NULL;
}
#endif