ReactOS 0.4.16-dev-959-g2ec3a19
memicmp.cpp File Reference
#include <corecrt_internal.h>
#include <ctype.h>
#include <locale.h>
#include <string.h>
Include dependency graph for memicmp.cpp:

Go to the source code of this file.

Functions

int __cdecl _memicmp_l (void const *const lhs, void const *const rhs, size_t const count, _locale_t const plocinfo)
 
int __cdecl __ascii_memicmp (void const *const lhs, void const *const rhs, size_t const count)
 
int __cdecl _memicmp (void const *const lhs, void const *const rhs, size_t const count)
 

Function Documentation

◆ __ascii_memicmp()

int __cdecl __ascii_memicmp ( void const *const  lhs,
void const *const  rhs,
size_t const  count 
)

Definition at line 77 of file memicmp.cpp.

82{
83 if (count == 0)
84 {
85 return 0;
86 }
87
88 unsigned char const * lhs_ptr = static_cast<unsigned char const *>(lhs);
89 unsigned char const * rhs_ptr = static_cast<unsigned char const *>(rhs);
90
91 int result;
92 size_t remaining = count;
93 do
94 {
95 result = __ascii_tolower(*lhs_ptr++) - __ascii_tolower(*rhs_ptr++);
96 }
97 while (result == 0 && --remaining != 0);
98
99 return result;
100}
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint64EXT * result
Definition: glext.h:11304
__forceinline int __CRTDECL __ascii_tolower(int const _C)
Definition: ctype.h:152

Referenced by _memicmp().

◆ _memicmp()

int __cdecl _memicmp ( void const *const  lhs,
void const *const  rhs,
size_t const  count 
)

Definition at line 104 of file memicmp.cpp.

109{
110 if (!__acrt_locale_changed())
111 {
112 /* validation section */
113 _VALIDATE_RETURN(lhs != nullptr || count == 0, EINVAL, _NLSCMPERROR);
114 _VALIDATE_RETURN(rhs != nullptr || count == 0, EINVAL, _NLSCMPERROR);
115
116 return __ascii_memicmp(lhs, rhs, count);
117 }
118
119 return _memicmp_l(lhs, rhs, count, nullptr);
120}
#define EINVAL
Definition: acclib.h:90
#define _VALIDATE_RETURN(expr, errorcode, retexpr)
int __cdecl _memicmp_l(void const *const lhs, void const *const rhs, size_t const count, _locale_t const plocinfo)
Definition: memicmp.cpp:41
int __cdecl __ascii_memicmp(void const *const lhs, void const *const rhs, size_t const count)
Definition: memicmp.cpp:77
#define _NLSCMPERROR
Definition: string.h:19

◆ _memicmp_l()

int __cdecl _memicmp_l ( void const *const  lhs,
void const *const  rhs,
size_t const  count,
_locale_t const  plocinfo 
)

Definition at line 41 of file memicmp.cpp.

47{
48 /* validation section */
49 _VALIDATE_RETURN(lhs != nullptr || count == 0, EINVAL, _NLSCMPERROR);
50 _VALIDATE_RETURN(rhs != nullptr || count == 0, EINVAL, _NLSCMPERROR);
51
52 if (count == 0)
53 {
54 return 0;
55 }
56
57 unsigned char const * lhs_ptr = static_cast<unsigned char const *>(lhs);
58 unsigned char const * rhs_ptr = static_cast<unsigned char const *>(rhs);
59
60 _LocaleUpdate _loc_update(plocinfo);
61
62 int result;
63 size_t remaining = count;
64 do
65 {
66 result = _tolower_fast_internal(*lhs_ptr++, _loc_update.GetLocaleT())
67 - _tolower_fast_internal(*rhs_ptr++, _loc_update.GetLocaleT());
68 }
69 while (result == 0 && --remaining != 0);
70
71 return result;
72}
_Check_return_ __forceinline unsigned char __cdecl _tolower_fast_internal(_In_ unsigned char const c, _In_ _locale_t const locale)
_locale_t plocinfo
Definition: ismbbyte.cpp:75

Referenced by _memicmp().