ReactOS 0.4.16-dev-737-g3368adc
strnlen.cpp File Reference
#include <corecrt_internal.h>
#include <corecrt_internal_simd.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for strnlen.cpp:

Go to the source code of this file.

Namespaces

namespace  anonymous_namespace{strnlen.cpp}
 

Enumerations

enum  anonymous_namespace{strnlen.cpp}::strnlen_mode { anonymous_namespace{strnlen.cpp}::bounded , anonymous_namespace{strnlen.cpp}::unbounded }
 

Functions

template<strnlen_mode Mode>
static __forceinline bool __cdecl last_reached (void const *const it, void const *const last) throw ()
 
template<>
__forceinline bool __cdecl last_reached< unbounded > (void const *const it, void const *const last) throw ()
 
template<strnlen_mode Mode, typename Element >
_Check_return_ _When_ (maximum_count > _String_length_(string), _Post_satisfies_(return==_String_length_(string))) _When_(maximum_count< = _String_length_(string)
 
_Check_return_ _Post_satisfies_ (return==maximum_count)) static __forceinline size_t __cdecl common_strnlen_c(Element const *const string
 
_Check_return_ size_t const maximum_count throw ()
 
size_t __cdecl strnlen (char const *const string, size_t const maximum_count)
 
size_t __cdecl wcsnlen (wchar_t const *const string, size_t const maximum_count)
 
size_t __cdecl wcslen (wchar_t const *const string)
 

Function Documentation

◆ _Post_satisfies_()

_Check_return_ _Post_satisfies_ ( return  = = maximum_count) const

◆ _When_()

template<strnlen_mode Mode, typename Element >
_Check_return_ _When_ ( maximum_count  ,
_String_length_(string ,
_Post_satisfies_(return==_String_length_(string))   
) = _String_length_(string)

◆ last_reached()

template<strnlen_mode Mode>
static __forceinline bool __cdecl last_reached ( void const *const  it,
void const *const  last 
)
throw (
)
static

Definition at line 37 of file strnlen.cpp.

41{
42 return it == last;
43}
static UINT UINT last
Definition: font.c:45

◆ last_reached< unbounded >()

template<>
__forceinline bool __cdecl last_reached< unbounded > ( void const *const  it,
void const *const  last 
)
throw (
)

Definition at line 46 of file strnlen.cpp.

50{
53
54 return false;
55}
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325

◆ strnlen()

size_t __cdecl strnlen ( char const *const  string,
size_t const  maximum_count 
)

◆ throw()

_Check_return_ size_t const maximum_count throw ( )

Definition at line 67 of file strnlen.cpp.

68{
69 Element const* const last = string + maximum_count;
70 Element const* it = string;
71
72 for (; !last_reached<Mode>(it, last) && *it != '\0'; ++it)
73 {
74 }
75
76 return static_cast<size_t>(it - string);
77}
char string[160]
Definition: util.h:11

◆ wcslen()

size_t __cdecl wcslen ( wchar_t const *const  string)

Definition at line 220 of file strnlen.cpp.

223{
224 return common_strnlen<unbounded>(reinterpret_cast<uint16_t const*>(string), _CRT_UNBOUNDED_BUFFER_SIZE);
225}
unsigned short int uint16_t
Definition: acefiex.h:54
#define _CRT_UNBOUNDED_BUFFER_SIZE

◆ wcsnlen()