From bbed653cda6007426e8291a5d32963552cc4f417 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 21 Jan 1996 10:01:05 +0000 Subject: Sun Jan 21 00:55:25 1996 Roland McGrath * sysdeps/unix/sysv/linux/shmat.c: Include sys/shm.h instead of sys/sem.h. * stdlib/stdlib.h [__USE_SVID]: Declare a64l, l64a. * stdlib/l64a.c: Use 6-bit numbers as indices in CONV_TABLE, not literal byte values. * misc/bsd-compat.c (getpgrp): Define with prototype. * misc/init-misc.c (__progname_full): New variable. (program_invocation_name, program_invocation_short_name): New aliases. (__init_misc): Define with prototype. Set __progname_full. * misc/progname.c: File removed. * misc/Makefile (aux): Remove progname. * misc/hsearch_r.c (isprime): Define with prototype. * sysdeps/unix/sysv/linux/seteuid.c: Just include unix/bsd version. * sysdeps/unix/bsd/seteuid.c: Disallow arg of -1. * sysdeps/unix/bsd/setegid.c: Likewise. --- misc/hsearch_r.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'misc/hsearch_r.c') diff --git a/misc/hsearch_r.c b/misc/hsearch_r.c index 5ea1d5e..86dbe79 100644 --- a/misc/hsearch_r.c +++ b/misc/hsearch_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1995 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc. Contributed by Ulrich Drepper This file is part of the GNU C Library. @@ -31,7 +31,7 @@ Boston, MA 02111-1307, USA. */ Instead the interface of all functions is extended to take an argument which describes the current status. */ typedef struct _ENTRY -{ +{ int used; ENTRY entry; } @@ -44,8 +44,7 @@ _ENTRY; a) the code is (most probably) called a few times per program run and b) the number is small because the table must fit in the core */ static int -isprime (number) - unsigned int number; +isprime (unsigned int number) { /* no even number will be passed */ unsigned int div = 3; @@ -61,7 +60,7 @@ isprime (number) Test for an existing table are done. We allocate one element more as the found prime number says. This is done for more effective indexing as explained in the comment for the hsearch function. - The contents of the table is zeroed, especially the field used + The contents of the table is zeroed, especially the field used becomes zero. */ int hcreate_r (nel, htab) @@ -114,7 +113,7 @@ hdestroy_r (htab) /* free used memory */ free (htab->table); - /* the sign for an existing table is an value != NULL in htable */ + /* the sign for an existing table is an value != NULL in htable */ htab->table = NULL; } @@ -124,7 +123,7 @@ hdestroy_r (htab) probably strings of chars. The function for generating a number of the strings is simple but fast. It can be replaced by a more complex function like ajw (see [Aho,Sethi,Ullman]) if the needs are shown. - + We use an trick to speed up the lookup. The table is created by hcreate with one more element available. This enables us to use the index zero special. This index will never be used because we store the first hash @@ -144,7 +143,7 @@ hsearch_r (item, action, retval, htab) unsigned int len = strlen (item.key); unsigned int idx; - /* If table is full and another entry should be entered return with + /* If table is full and another entry should be entered return with error. */ if (action == ENTER && htab->filled == htab->size) { @@ -178,7 +177,7 @@ hsearch_r (item, action, retval, htab) if (htab->table[idx].used == hval && strcmp (item.key, htab->table[idx].entry.key) == 0) { - if (action == ENTER) + if (action == ENTER) htab->table[idx].entry.data = item.data; *retval = &htab->table[idx].entry; @@ -187,7 +186,7 @@ hsearch_r (item, action, retval, htab) /* Second hash function, as suggested in [Knuth] */ hval2 = 1 + hval % (htab->size - 2); - + do { /* Because SIZE is prime this guarantees to step through all @@ -201,7 +200,7 @@ hsearch_r (item, action, retval, htab) if (htab->table[idx].used == hval && strcmp (item.key, htab->table[idx].entry.key) == 0) { - if (action == ENTER) + if (action == ENTER) htab->table[idx].entry.data = item.data; *retval = &htab->table[idx].entry; -- cgit v1.1