mirror of
https://github.com/postgres/postgres.git
synced 2025-11-15 03:41:20 +03:00
Rewrite strnlen replacement implementation from 8a241792f9.
The previous placement of the fallback implementation in libpgcommon was problematic, because libpqport functions need strnlen functionality. Move replacement into libpgport. Provide strnlen() under its posix name, instead of pg_strnlen(). Fix stupid configure bug, executing the test only when compiled with threading support. Author: Andres Freund Discussion: https://postgr.es/m/E1e1gR2-0005fB-SI@gemulon.postgresql.org
This commit is contained in:
@@ -41,23 +41,3 @@ pg_str_endswith(const char *str, const char *end)
|
||||
str += slen - elen;
|
||||
return strcmp(str, end) == 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Portable version of posix' strnlen.
|
||||
*
|
||||
* Returns the number of characters before a null-byte in the string pointed
|
||||
* to by str, unless there's no null-byte before maxlen. In the latter case
|
||||
* maxlen is returned.
|
||||
*/
|
||||
#ifndef HAVE_STRNLEN
|
||||
size_t
|
||||
pg_strnlen(const char *str, size_t maxlen)
|
||||
{
|
||||
const char *p = str;
|
||||
|
||||
while (maxlen-- > 0 && *p)
|
||||
p++;
|
||||
return p - str;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user