ReactOS 0.4.16-dev-937-g7afcd2a
lfind.cpp File Reference
#include <corecrt_internal.h>
#include <search.h>
Include dependency graph for lfind.cpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define __fileDECL   __cdecl
 
#define __COMPARE(context, p1, p2)   (*compare)(p1, p2)
 

Functions

void *__fileDECL _lfind (void const *const key, void const *const base, unsigned int *const num, unsigned int const width, int(__fileDECL *const compare)(void const *, void const *))
 

Macro Definition Documentation

◆ __COMPARE

#define __COMPARE (   context,
  p1,
  p2 
)    (*compare)(p1, p2)

Definition at line 22 of file lfind.cpp.

◆ __fileDECL

#define __fileDECL   __cdecl

Definition at line 14 of file lfind.cpp.

Function Documentation

◆ _lfind()

void *__fileDECL _lfind ( void const *const  key,
void const *const  base,
unsigned int *const  num,
unsigned int const  width,
int(__fileDECL *const compare)(void const *, void const *)   
)

Definition at line 51 of file lfind.cpp.

59{
60 _VALIDATE_RETURN(key != nullptr, EINVAL, nullptr);
61 _VALIDATE_RETURN(num != nullptr, EINVAL, nullptr);
62 _VALIDATE_RETURN(base != nullptr || *num == 0, EINVAL, nullptr);
63 _VALIDATE_RETURN(width > 0, EINVAL, nullptr);
64 _VALIDATE_RETURN(compare != nullptr, EINVAL, nullptr);
65
66 char const* const first = static_cast<char const*>(base);
67 char const* const last = first + *num * width;
68
69 for (char const* p = first; p != last; p += width)
70 {
71 if (__COMPARE(context, key, const_cast<char*>(p)) == 0)
72 {
73 return const_cast<char*>(p);
74 }
75 }
76
77 return nullptr;
78}
#define EINVAL
Definition: acclib.h:90
#define _VALIDATE_RETURN(expr, errorcode, retexpr)
GLint GLint GLsizei width
Definition: gl.h:1546
const GLint * first
Definition: glext.h:5794
GLfloat GLfloat p
Definition: glext.h:8902
GLuint GLuint num
Definition: glext.h:9618
#define __COMPARE(context, p1, p2)
Definition: lfind.cpp:22
static UINT UINT last
Definition: font.c:45
Definition: bug.cpp:8
Definition: http.c:7252
Definition: copy.c:22
#define const
Definition: zconf.h:233