mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-16 18:10:11 +00:00
509d1b6842
* misc/hsearch_r.c: Add libc_hidden_def. * misc/lsearch.c: Likewise. * include/ttyent.h: Use libc_hidden_proto for getttyent, setttyent, endttyent. * misc/getttyent.c: Add libc_hidden_def. * include/mcheck.h: Use libc_hidden_proto for mcheck. * malloc/mcheck.c: Add libc_hidden_def. * include/envz.h: Use libc_hidden_proto for envz_entry, enz_remove. * include/argz.h: Use libc_hidden_proto for argz_delete. * string/argz-delete.c: Add libc_hidden_def. * string/envz.c: Likewise. Use <envz.h>, not "envz.h". * sysdeps/unix/sysv/linux/x86_64/clone.S (thread_start): Use HIDDEN_JUMPTARGET for _exit. * sysdeps/unix/sysv/linux/m68k/clone.S (thread_start): Likewise. * sysdeps/unix/sysv/linux/i386/clone.S (thread_start): Likewise. * sysdeps/unix/sysv/linux/powerpc/clone.S: Likewise. * sysdeps/unix/_exit.S (_exit): Add libc_hidden_def. * include/libc-symbols.h: Fix [__ASSEMBLY__] -> [__ASSEMBLER__]. [__ASSEMBLER__] (hidden_weak): Define using hidden_def, or to empty. [__ASSEMBLER__] (HIDDEN_JUMPTARGET): New macro. * sysdeps/unix/sysv/linux/i386/makecontext.S: Use it for exit. * include/stdlib.h: Use libc_hidden_proto for abort, __strtof_internal, __strtod_internal, __strtold_internal, __strtol_internal, __strtoll_internal, __strtoul_internal, __strtoull_internal. __strtof_l_internal, __strtod_l_internal, __strtold_l_internal, __strtol_l_internal, __strtoll_l_internal, __strtoul_l_internal, __strtoull_l_internal. * include/wchar.h: Use libc_hidden_proto for __wcstof_internal, __wcstod_internal, __wcstold_internal, __wcstol_internal, __wcstoll_internal, __wcstoul_internal, ____wcstof_l_internal, ____wcstod_l_internal, ____wcstold_l_internal, ____wcstol_l_internal, ____wcstoll_l_internal, ____wcstoul_l_internal, __wcscasecmp_l, __wcsncasecmp_l. * sysdeps/generic/abort.c: Add libc_hidden_def. * stdlib/strtod.c: Likewise. * sysdeps/generic/strtol.c: Likewise. * sysdeps/wordsize-64/strtol.c: Likewise. * sysdeps/wordsize-64/wcstol.c: Likewise. * sysdeps/wordsize-64/wcstol_l.c: Likewise.
60 lines
1.7 KiB
C
60 lines
1.7 KiB
C
/* Linear search functions.
|
|
Copyright (C) 1996,97,98,2002 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, write to the Free
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
02111-1307 USA. */
|
|
|
|
#include <search.h>
|
|
#include <string.h>
|
|
|
|
|
|
void *
|
|
lsearch (const void *key, void *base, size_t *nmemb, size_t size,
|
|
__compar_fn_t compar)
|
|
{
|
|
void *result;
|
|
|
|
/* Try to find it. */
|
|
result = lfind (key, base, nmemb, size, compar);
|
|
if (result == NULL)
|
|
{
|
|
/* Not available. Insert at the end. */
|
|
result = memcpy (base + (*nmemb) * size, key, size);
|
|
++(*nmemb);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
void *
|
|
lfind (const void *key, const void *base, size_t *nmemb, size_t size,
|
|
__compar_fn_t compar)
|
|
{
|
|
const void *result = base;
|
|
size_t cnt = 0;
|
|
|
|
while (cnt < *nmemb && (*compar) (key, result) != 0)
|
|
{
|
|
result += size;
|
|
++cnt;
|
|
}
|
|
|
|
return cnt < *nmemb ? (void *) result : NULL;
|
|
}
|
|
libc_hidden_def (lfind)
|