OSDN Git Service

FORTIFY_SOURCE: strcat / strncat optimize
authorNick Kralevich <nnk@google.com>
Thu, 30 May 2013 23:48:53 +0000 (16:48 -0700)
committerNick Kralevich <nnk@google.com>
Fri, 31 May 2013 16:07:46 +0000 (09:07 -0700)
commitcf870199d576bdfc339b7fb016c9f6fe7f2c87ed
treee4bdb361862de3efd9b907379d0fe3f2ad3f4ae2
parent72f59c84fd73a0a701ce6448d103e9021c1cb060
FORTIFY_SOURCE: strcat / strncat optimize

__strcat_chk and __strncat_chk are slightly inefficient,
because they end up traversing over the same memory region
two times.

This change optimizes __strcat_chk / __strncat_chk so they
only access the memory once. Although I haven't benchmarked these
changes, it should improve the performance of these functions.

__strlen_chk - expose this function, even if -D_FORTIFY_SOURCE
isn't defined. This is needed to compile libc itself without
-D_FORTIFY_SOURCE.

Change-Id: Id2c70dff55a276b47c59db27a03734d659f84b74
libc/bionic/__strcat_chk.cpp
libc/bionic/__strncat_chk.cpp
libc/include/string.h
libc/private/libc_logging.h
tests/fortify1_test.cpp
tests/fortify2_test.cpp
tests/string_test.cpp