This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 1/3] Implement bzero() via memset()


Use memset() to implement bzero() to profit from machine-specific
memset() optimizations.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
---
 newlib/libc/string/bzero.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/newlib/libc/string/bzero.c b/newlib/libc/string/bzero.c
index dbcae02d6..e99529af6 100644
--- a/newlib/libc/string/bzero.c
+++ b/newlib/libc/string/bzero.c
@@ -30,14 +30,11 @@ Neither ANSI C nor the System V Interface Definition (Issue 2) require
 <<bzero>> requires no supporting OS subroutines.
 */
 
-#include <strings.h>
+#include <string.h>
 
-_VOID
-_DEFUN (bzero, (b, length),
-	void *b _AND
-	size_t length)
+void
+bzero(void *b, size_t length)
 {
-  char *ptr = (char *)b;
-  while (length--)
-    *ptr++ = 0;
+
+	memset(b, 0, length);
 }
-- 
2.12.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]