changeset 480:f558dce66095

Nathan McSween convinced me compilers that inline memset() can optimize the bzero case pretty well.
author Rob Landley <rob@landley.net>
date Sat, 18 Feb 2012 22:44:11 -0600
parents 1a7110479d49
children e1b9a8579ddb
files lib/args.c lib/lib.c main.c toys/toysh.c
diffstat 4 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lib/args.c	Sat Feb 18 18:54:30 2012 -0600
+++ b/lib/args.c	Sat Feb 18 22:44:11 2012 -0600
@@ -181,7 +181,7 @@
 	int i;
 
 	// Parse option format string
-	bzero(gof, sizeof(struct getoptflagstate));
+	memset(gof, 0, sizeof(struct getoptflagstate));
 	gof->maxargs = INT_MAX;
 	if (!options) return;
 
--- a/lib/lib.c	Sat Feb 18 18:54:30 2012 -0600
+++ b/lib/lib.c	Sat Feb 18 22:44:11 2012 -0600
@@ -91,7 +91,7 @@
 void *xzalloc(size_t size)
 {
 	void *ret = xmalloc(size);
-	bzero(ret, size);
+	memset(ret, 0, size);
 	return ret;
 }
 
--- a/main.c	Sat Feb 18 18:54:30 2012 -0600
+++ b/main.c	Sat Feb 18 22:44:11 2012 -0600
@@ -84,7 +84,7 @@
 	// Free old toys contents (to be reentrant)
 
 	if (toys.optargs != toys.argv+1) free(toys.optargs);
-	bzero(&toys, sizeof(struct toy_context));
+	memset(&toys, 0, sizeof(struct toy_context));
 
 	toys.which = which;
 	toys.argv = argv;
--- a/toys/toysh.c	Sat Feb 18 18:54:30 2012 -0600
+++ b/toys/toysh.c	Sat Feb 18 22:44:11 2012 -0600
@@ -291,7 +291,7 @@
 
 		// This fakes lots of what toybox_main() does.
 		memcpy(&temp, &toys, sizeof(struct toy_context));
-		bzero(&toys, sizeof(struct toy_context));
+		memset(&toys, 0, sizeof(struct toy_context));
 		toy_init(tl, cmd->argv);
 		tl->toy_main();
 		cmd->pid = toys.exitval;