mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 22:33:00 +00:00
Create a branch for network fixes.
svn path=/branches/aicom-network-fixes/; revision=34994
This commit is contained in:
parent
0e213bbc00
commit
c501d8112c
18148 changed files with 0 additions and 860488 deletions
28
lib/sdk/crt/search/bsearch.c
Normal file
28
lib/sdk/crt/search/bsearch.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdlib.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
void *
|
||||
bsearch(const void *key, const void *base0, size_t nelem,
|
||||
size_t size, int (*cmp)(const void *ck, const void *ce))
|
||||
{
|
||||
char *base = (char *)base0;
|
||||
int lim, cmpval;
|
||||
void *p;
|
||||
|
||||
for (lim = nelem; lim != 0; lim >>= 1)
|
||||
{
|
||||
p = base + (lim >> 1) * size;
|
||||
cmpval = (*cmp)(key, p);
|
||||
if (cmpval == 0)
|
||||
return p;
|
||||
if (cmpval > 0)
|
||||
{ /* key > p: move right */
|
||||
base = (char *)p + size;
|
||||
lim--;
|
||||
} /* else move left */
|
||||
}
|
||||
return 0;
|
||||
}
|
21
lib/sdk/crt/search/lfind.c
Normal file
21
lib/sdk/crt/search/lfind.c
Normal file
|
@ -0,0 +1,21 @@
|
|||
#include <search.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
void *_lfind(const void *key, const void *base, size_t *nelp,
|
||||
size_t width, int (*compar)(const void *, const void *))
|
||||
{
|
||||
char* char_base = (char*)base;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < *nelp; i++) {
|
||||
if (compar(key, char_base) == 0)
|
||||
return char_base;
|
||||
char_base += width;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
21
lib/sdk/crt/search/lsearch.c
Normal file
21
lib/sdk/crt/search/lsearch.c
Normal file
|
@ -0,0 +1,21 @@
|
|||
#include <search.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
void *_lsearch(const void *key, void *base, size_t *nelp, size_t width,
|
||||
int (*compar)(const void *, const void *))
|
||||
{
|
||||
void *ret_find = _lfind(key,base,nelp,width,compar);
|
||||
|
||||
if (ret_find != NULL)
|
||||
return ret_find;
|
||||
|
||||
memcpy((void*)((int*)base + (*nelp*width)), key, width);
|
||||
|
||||
(*nelp)++;
|
||||
return base;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue