Stylefixes as pointed out by Axel and some minor changes possible in cpp.
No functional change.
This commit is contained in:
@@ -17,20 +17,22 @@ size_t
|
|||||||
strlen(const char* string)
|
strlen(const char* string)
|
||||||
{
|
{
|
||||||
size_t length = 0;
|
size_t length = 0;
|
||||||
uint32* valuePointer;
|
|
||||||
|
|
||||||
/* Align access for four byte reads */
|
/* Align access for four byte reads */
|
||||||
for (; (((addr_t)string + length) & 3) != 0; length++)
|
for (; (((addr_t)string + length) & 3) != 0; length++) {
|
||||||
if (string[length] == '\0')
|
if (string[length] == '\0')
|
||||||
return length;
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check four bytes for zero char */
|
/* Check four bytes for zero char */
|
||||||
for (valuePointer = (uint32*)(string + length);
|
uint32* valuePointer = (uint32*)(string + length);
|
||||||
LACKS_ZERO_BYTE(*valuePointer); valuePointer++);
|
for (; LACKS_ZERO_BYTE(*valuePointer); valuePointer++)
|
||||||
|
;
|
||||||
|
|
||||||
/* Find the exact length */
|
/* Find the exact length */
|
||||||
for (length = ((char*)valuePointer) - string; string[length] != '\0';
|
for (length = ((char*)valuePointer) - string; string[length] != '\0';
|
||||||
length++);
|
length++)
|
||||||
|
;
|
||||||
|
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,23 +17,23 @@ size_t
|
|||||||
strnlen(const char* string, size_t count)
|
strnlen(const char* string, size_t count)
|
||||||
{
|
{
|
||||||
size_t length = 0;
|
size_t length = 0;
|
||||||
uint32* valuePointer;
|
|
||||||
uint32* maxScanPosition;
|
|
||||||
|
|
||||||
/* Align access for four byte reads */
|
/* Align access for four byte reads */
|
||||||
for (; (((addr_t)string + length) & 3) != 0; length++)
|
for (; (((addr_t)string + length) & 3) != 0; length++) {
|
||||||
if (length == count || string[length] == '\0')
|
if (length == count || string[length] == '\0')
|
||||||
return length;
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check four bytes for zero char */
|
/* Check four bytes for zero char */
|
||||||
maxScanPosition = (uint32*)(string + count - 4);
|
const uint32* kMaxScanPosition = (uint32*)(string + count - 4);
|
||||||
for (valuePointer = (uint32*)(string + length);
|
uint32* valuePointer = (uint32*)(string + length);
|
||||||
valuePointer <= maxScanPosition && LACKS_ZERO_BYTE(*valuePointer);
|
for (; valuePointer <= kMaxScanPosition && LACKS_ZERO_BYTE(*valuePointer);
|
||||||
valuePointer++);
|
valuePointer++)
|
||||||
|
;
|
||||||
|
|
||||||
/* Find the exact length */
|
/* Find the exact length */
|
||||||
for (length = ((char*)valuePointer) - string; length < count
|
for (length = ((char*)valuePointer) - string; length < count
|
||||||
&& string[length] != '\0'; length++);
|
&& string[length] != '\0'; length++)
|
||||||
|
;
|
||||||
|
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user