Browse Source

Implement __tfind/__lfind and use them

Peter S. Mazinger 20 years ago
parent
commit
960acb5e32
2 changed files with 8 additions and 3 deletions
  1. 6 2
      libc/misc/search/lsearch.c
  2. 2 1
      libc/misc/search/tsearch.c

+ 6 - 2
libc/misc/search/lsearch.c

@@ -14,7 +14,7 @@
 
 #ifdef L_lfind
 
-void *lfind(const void *key, const void *base, size_t *nmemb,
+void attribute_hidden *__lfind(const void *key, const void *base, size_t *nmemb,
 	size_t size, int (*compar)(const void *, const void *))
 {
 	register int n = *nmemb;
@@ -26,17 +26,21 @@ void *lfind(const void *key, const void *base, size_t *nmemb,
 	}
 	return (NULL);
 }
+strong_alias(__lfind,lfind)
 
 #endif
 
 #ifdef L_lsearch
 
+extern void *__lfind (__const void *__key, __const void *__base,
+		    size_t *__nmemb, size_t __size, __compar_fn_t __compar) attribute_hidden;
+
 void *lsearch(const void *key, void *base, size_t *nmemb, 
 	size_t size, int (*compar)(const void *, const void *))
 {
 	register char *p;
 
-	if ((p = lfind(key, base, nmemb, size, compar)) == NULL) {
+	if ((p = __lfind(key, base, nmemb, size, compar)) == NULL) {
 		p = __memcpy((base + (size * (*nmemb))), key, size);
 		++(*nmemb);
 	}

+ 2 - 1
libc/misc/search/tsearch.c

@@ -81,7 +81,7 @@ strong_alias(__tsearch,tsearch)
 #endif
 
 #ifdef L_tfind
-void *tfind(__const void *key, void * __const *vrootp, __compar_fn_t compar)
+void attribute_hidden *__tfind(__const void *key, void * __const *vrootp, __compar_fn_t compar)
 {
     register node **rootp = (node **) vrootp;
 
@@ -99,6 +99,7 @@ void *tfind(__const void *key, void * __const *vrootp, __compar_fn_t compar)
     }
     return NULL;
 }
+strong_alias(__tfind,tfind)
 #endif
 
 #ifdef L_tdelete