aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2003-03-28 04:23:23 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2003-03-28 04:23:23 +0000
commit56c633c1396aa8c11b92702041439fa1041fe7bb (patch)
tree9a62f20540beb0736a02235f2e737e49895f49a8
parentc949bfa555cb844bd867b7c9fdf1874647df3543 (diff)
downloadbusybox-w32-56c633c1396aa8c11b92702041439fa1041fe7bb.tar.gz
busybox-w32-56c633c1396aa8c11b92702041439fa1041fe7bb.tar.bz2
busybox-w32-56c633c1396aa8c11b92702041439fa1041fe7bb.zip
make sed cleanup use linked list
-rw-r--r--editors/sed.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/editors/sed.c b/editors/sed.c
index 85eb9f68d..037d2a8ac 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -118,30 +118,27 @@ const char * const semicolon_whitespace = "; \n\r\t\v\0";
118#ifdef CONFIG_FEATURE_CLEAN_UP 118#ifdef CONFIG_FEATURE_CLEAN_UP
119static void destroy_cmd_strs(void) 119static void destroy_cmd_strs(void)
120{ 120{
121 if (sed_cmds == NULL) 121 sed_cmd_t *sed_cmd = sed_cmd_head.linear;
122 return;
123 122
124 /* destroy all the elements in the array */ 123 while (sed_cmd) {
125 while (--ncmds >= 0) { 124 sed_cmd_t *sed_cmd_next = sed_cmd->linear;
126 125
127 if (sed_cmds[ncmds]->beg_match) { 126 if (sed_cmd->beg_match) {
128 regfree(sed_cmds[ncmds]->beg_match); 127 regfree(sed_cmd->beg_match);
129 free(sed_cmds[ncmds]->beg_match); 128 free(sed_cmd->beg_match);
130 } 129 }
131 if (sed_cmds[ncmds]->end_match) { 130 if (sed_cmd->end_match) {
132 regfree(sed_cmds[ncmds]->end_match); 131 regfree(sed_cmd->end_match);
133 free(sed_cmds[ncmds]->end_match); 132 free(sed_cmd->end_match);
134 } 133 }
135 if (sed_cmds[ncmds]->sub_match) { 134 if (sed_cmd->sub_match) {
136 regfree(sed_cmds[ncmds]->sub_match); 135 regfree(sed_cmd->sub_match);
137 free(sed_cmds[ncmds]->sub_match); 136 free(sed_cmd->sub_match);
138 } 137 }
139 free(sed_cmds[ncmds]->replace); 138 free(sed_cmd->replace);
139 free(sed_cmd);
140 sed_cmd = sed_cmd_next;
140 } 141 }
141
142 /* destroy the array */
143 free(sed_cmds);
144 sed_cmds = NULL;
145} 142}
146#endif 143#endif
147 144