OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uC-libc/] [misc/] [lsearch.c] - Blame information for rev 1775

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/*
2
 * This file lifted in toto from 'Dlibs' on the atari ST  (RdeBath)
3
 *
4
 *
5
 *    Dale Schumacher                         399 Beacon Ave.
6
 *    (alias: Dalnefre')                      St. Paul, MN  55104
7
 *    dal@syntel.UUCP                         United States of America
8
 *  "It's not reality that's important, but how you perceive things."
9
 */
10
 
11
#include <stdio.h>
12
 
13
char *
14
lfind(key, base, num, size, cmp)
15
register char *key, *base;
16
unsigned int *num;
17
register unsigned int size;
18
register int (*cmp) ();
19
{
20
   register int n = *num;
21
 
22
   while (n--)
23
   {
24
      if ((*cmp) (base, key) == 0)
25
         return (base);
26
      base += size;
27
   }
28
   return (NULL);
29
}
30
 
31
char *
32
lsearch(key, base, num, size, cmp)
33
char *key, *base;
34
register unsigned int *num;
35
register unsigned int size;
36
int   (*cmp) ();
37
{
38
   register char *p;
39
   char *memcpy();
40
 
41
   if ((p = lfind(key, base, num, size, cmp)) == NULL)
42
   {
43
      p = memcpy((base + (size * (*num))), key, size);
44
      ++(*num);
45
   }
46
   return (p);
47
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.