diff options
Diffstat (limited to 'lib/libc/db/hash')
| -rw-r--r-- | lib/libc/db/hash/hash.c | 21 | ||||
| -rw-r--r-- | lib/libc/db/hash/hash_page.c | 19 | ||||
| -rw-r--r-- | lib/libc/db/hash/hsearch.c | 4 | ||||
| -rw-r--r-- | lib/libc/db/hash/ndbm.c | 4 | 
4 files changed, 25 insertions, 23 deletions
diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c index aa2e42856ebe..e9b25831d20e 100644 --- a/lib/libc/db/hash/hash.c +++ b/lib/libc/db/hash/hash.c @@ -35,7 +35,7 @@   */  #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hash.c	8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)hash.c	8.4 (Berkeley) 10/12/93";  #endif /* LIBC_SCCS and not lint */  #include <sys/param.h> @@ -93,9 +93,9 @@ long hash_accesses, hash_collisions, hash_expansions, hash_overflows;  /* OPEN/CLOSE */  extern DB * -__hash_open(file, flags, mode, info) +__hash_open(file, flags, mode, info, dflags)  	const char *file; -	int flags, mode; +	int flags, mode, dflags;  	const HASHINFO *info;	/* Special directives for create */  {  	HTAB *hashp; @@ -111,13 +111,14 @@ __hash_open(file, flags, mode, info)  	if (!(hashp = calloc(1, sizeof(HTAB))))  		return (NULL);  	hashp->fp = -1; +  	/* -	 * Select flags relevant to us. Even if user wants write only, we need -	 * to be able to read the actual file, so we need to open it read/write. -	 * But, the field in the hashp structure needs to be accurate so that +	 * Even if user wants write only, we need to be able to read +	 * the actual file, so we need to open it read/write. But, the +	 * field in the hashp structure needs to be accurate so that  	 * we can check accesses.  	 */ -	hashp->flags = flags = flags & __USE_OPEN_FLAGS; +	hashp->flags = flags;  	new_table = 0;  	if (!file || (flags & O_TRUNC) || @@ -152,7 +153,9 @@ __hash_open(file, flags, mode, info)  		/* Verify file type, versions and hash function */  		if (hashp->MAGIC != HASHMAGIC)  			RETURN_ERROR(EFTYPE, error1); -		if (hashp->VERSION != HASHVERSION) +#define	OLDHASHVERSION	1 +		if (hashp->VERSION != HASHVERSION && +		    hashp->VERSION != OLDHASHVERSION)  			RETURN_ERROR(EFTYPE, error1);  		if (hashp->hash(CHARKEY, sizeof(CHARKEY)) != hashp->H_CHARKEY)  			RETURN_ERROR(EFTYPE, error1); @@ -865,7 +868,7 @@ hash_realloc(p_ptr, oldsize, newsize)  	if (p = malloc(newsize)) {  		memmove(p, *p_ptr, oldsize); -		memset(p + oldsize, 0, newsize - oldsize); +		memset((char *)p + oldsize, 0, newsize - oldsize);  		free(*p_ptr);  		*p_ptr = p;  	} diff --git a/lib/libc/db/hash/hash_page.c b/lib/libc/db/hash/hash_page.c index c2260f7b21a3..463189b15d2b 100644 --- a/lib/libc/db/hash/hash_page.c +++ b/lib/libc/db/hash/hash_page.c @@ -35,7 +35,7 @@   */  #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hash_page.c	8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)hash_page.c	8.2 (Berkeley) 9/6/93";  #endif /* LIBC_SCCS and not lint */  /* @@ -302,12 +302,8 @@ ugly_split(hashp, obucket, old_bufp, new_bufp, copyto, moved)  	n = ino[0] - 1;  	while (n < ino[0]) {  		if (ino[2] < REAL_KEY && ino[2] != OVFLPAGE) { -			/* -			 * Ov_addr gets set before reaching this point; there's -			 * always an overflow page before a big key/data page. -			 */  			if (__big_split(hashp, old_bufp, -			    new_bufp, bufp, ov_addr, obucket, &ret)) +			    new_bufp, bufp, bufp->addr, obucket, &ret))  				return (-1);  			old_bufp = ret.oldp;  			if (!old_bufp) @@ -409,11 +405,14 @@ __addel(hashp, bufp, key, val)  	bp = (u_short *)bufp->page;  	do_expand = 0; -	while (bp[0] && (bp[bp[0]] < REAL_KEY)) +	while (bp[0] && (bp[2] < REAL_KEY || bp[bp[0]] < REAL_KEY))  		/* Exception case */ -		if (bp[2] < REAL_KEY && bp[bp[0]] != OVFLPAGE) { -			/* This is a big-keydata pair */ -			bufp = __add_ovflpage(hashp, bufp); +		if (bp[2] == FULL_KEY_DATA && bp[0] == 2) +			/* This is the last page of a big key/data pair +			   and we need to add another page */ +			break; +		else if (bp[2] < REAL_KEY && bp[bp[0]] != OVFLPAGE) { +			bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);  			if (!bufp)  				return (-1);  			bp = (u_short *)bufp->page; diff --git a/lib/libc/db/hash/hsearch.c b/lib/libc/db/hash/hsearch.c index 30657b2c8ab6..8074d67945cf 100644 --- a/lib/libc/db/hash/hsearch.c +++ b/lib/libc/db/hash/hsearch.c @@ -35,7 +35,7 @@   */  #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hsearch.c	8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)hsearch.c	8.2 (Berkeley) 9/7/93";  #endif /* LIBC_SCCS and not lint */  #include <sys/types.h> @@ -62,7 +62,7 @@ hcreate(nel)  	info.cachesize = NULL;  	info.hash = NULL;  	info.lorder = 0; -	dbp = (DB *)__hash_open(NULL, O_CREAT | O_RDWR, 0600, &info); +	dbp = (DB *)__hash_open(NULL, O_CREAT | O_RDWR, 0600, &info, 0);  	return ((int)dbp);  } diff --git a/lib/libc/db/hash/ndbm.c b/lib/libc/db/hash/ndbm.c index 2756074744c2..89b9916566b2 100644 --- a/lib/libc/db/hash/ndbm.c +++ b/lib/libc/db/hash/ndbm.c @@ -35,7 +35,7 @@   */  #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)ndbm.c	8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)ndbm.c	8.2 (Berkeley) 9/11/93";  #endif /* LIBC_SCCS and not lint */  /* @@ -72,7 +72,7 @@ dbm_open(file, flags, mode)  	info.lorder = 0;  	(void)strcpy(path, file);  	(void)strcat(path, DBM_SUFFIX); -	return ((DBM *)__hash_open(path, flags, mode, &info)); +	return ((DBM *)__hash_open(path, flags, mode, &info, 0));  }  extern void  | 
