[git commit master] ash: even smaller `trap` code

Denys Vlasenko vda.linux at googlemail.com
Fri Sep 25 00:58:20 UTC 2009


commit: http://git.busybox.net/busybox/commit/?id=726e1a04f7fdf9a646614352cd8c4a371dda6eda
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
evalvar                                             1371    1373      +2
trapcmd                                              347     260     -87

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 shell/ash.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/shell/ash.c b/shell/ash.c
index 37bdc70..0cada04 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -4601,8 +4601,7 @@ forkchild(struct job *jp, union node *n, int mode)
 		 *
 		 * Our solution: ONLY bare $(trap) or `trap` is special.
 		 */
-		/* This is needed to prevent EXIT trap firing and such
-		 * (trap_ptr will be freed in trapcmd()) */
+		/* This is needed to prevent EXIT trap firing and such */
 		trap_ptr = memcpy(xmalloc(sizeof(trap)), trap, sizeof(trap));
 	}
 	clear_traps();
@@ -12271,14 +12270,18 @@ trapcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
 						single_quote(tr),
 						(signo == 0 ? "" : "SIG"),
 						get_signame(signo));
-				if (trap_ptr != trap)
-					free(tr);
+		/* trap_ptr != trap only if we are in special-cased `trap` code.
+		 * In this case, we will exit very soon, no need to free(). */
+				/* if (trap_ptr != trap) */
+				/*	free(tr); */
 			}
 		}
+		/*
 		if (trap_ptr != trap) {
 			free(trap_ptr);
 			trap_ptr = trap;
 		}
+		*/
 		return 0;
 	}
 
-- 
1.6.3.3



More information about the busybox-cvs mailing list