commit: c86b0416025b4b3f8555295a89c64e233803fef2
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Sep 20 20:41:28 2015 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Sep 20 20:41:28 2015 +0000
URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=c86b0416
libsandbox: use memchr to speed up NUL byte search
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
libsandbox/trace.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/libsandbox/trace.c b/libsandbox/trace.c
index ed05c4d..47d2bdf 100644
--- a/libsandbox/trace.c
+++ b/libsandbox/trace.c
@@ -123,9 +123,8 @@ static char *do_peekstr(unsigned long lptr)
strerror(e));
}
- for (i = 0; i < liov.iov_len; ++i)
- if (!((char *)liov.iov_base)[i])
- return ret;
+ if (memchr(liov.iov_base, '\0', liov.iov_len) != NULL)
+ return ret;
riov.iov_base += l;
riov.iov_len = liov.iov_len = l;
len += l;