diff options
author | Roland McGrath <roland@gnu.org> | 1996-01-29 19:30:15 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1996-01-29 19:30:15 +0000 |
commit | b86199fb609d691b0a12761621760aa52562e195 (patch) | |
tree | 1516836553fe8f661a017a509b36f3604d82cd36 /db | |
parent | 429ed67ba10dccfa6472bf803473fd20c0203309 (diff) | |
download | glibc-b86199fb609d691b0a12761621760aa52562e195.zip glibc-b86199fb609d691b0a12761621760aa52562e195.tar.gz glibc-b86199fb609d691b0a12761621760aa52562e195.tar.bz2 |
Set $inhibit_glue.
Diffstat (limited to 'db')
-rw-r--r-- | db/btree/bt_open.c | 22 | ||||
-rw-r--r-- | db/hash/hash.c | 14 | ||||
-rw-r--r-- | db/hash/hash.h | 22 | ||||
-rw-r--r-- | db/hash/ndbm.c | 21 |
4 files changed, 52 insertions, 27 deletions
diff --git a/db/btree/bt_open.c b/db/btree/bt_open.c index f052249..503db85 100644 --- a/db/btree/bt_open.c +++ b/db/btree/bt_open.c @@ -200,7 +200,7 @@ __bt_open(fname, flags, mode, openinfo, dflags) default: goto einval; } - + if ((t->bt_fd = open(fname, flags, mode)) < 0) goto err; @@ -388,18 +388,30 @@ tmp() { sigset_t set, oset; int fd; - char *envtmp; - char path[MAXPATHLEN]; + const char *envtmp; + char *path; + static const char fmt[] = "%s/bt.XXXXXX"; + size_t n; envtmp = getenv("TMPDIR"); - (void)snprintf(path, - sizeof(path), "%s/bt.XXXXXX", envtmp ? envtmp : "/tmp"); + if (!envtmp) + envtmp = "/tmp"; + n = strlen (envtmp) + sizeof fmt; +#ifdef __GNUC__ + path = __builtin_alloca(n); +#else + path = malloc(n); +#endif + (void)snprintf(path, n, fmt, envtmp ? envtmp : "/tmp"); (void)sigfillset(&set); (void)sigprocmask(SIG_BLOCK, &set, &oset); if ((fd = mkstemp(path)) != -1) (void)unlink(path); (void)sigprocmask(SIG_SETMASK, &oset, NULL); +#ifndef __GNUC__ + free(path); +#endif return(fd); } diff --git a/db/hash/hash.c b/db/hash/hash.c index 4b7b732..0db7b32 100644 --- a/db/hash/hash.c +++ b/db/hash/hash.c @@ -505,7 +505,7 @@ flush_meta(hashp) else if (wsize != sizeof(HASHHDR)) { errno = EFTYPE; - hashp->errno = errno; + hashp->errnum = errno; return (-1); } for (i = 0; i < NCACHED; i++) @@ -536,7 +536,7 @@ hash_get(dbp, key, data, flag) hashp = (HTAB *)dbp->internal; if (flag) { - hashp->errno = errno = EINVAL; + hashp->errnum = errno = EINVAL; return (ERROR); } return (hash_access(hashp, HASH_GET, (DBT *)key, data)); @@ -553,11 +553,11 @@ hash_put(dbp, key, data, flag) hashp = (HTAB *)dbp->internal; if (flag && flag != R_NOOVERWRITE) { - hashp->errno = errno = EINVAL; + hashp->errnum = errno = EINVAL; return (ERROR); } if ((hashp->flags & O_ACCMODE) == O_RDONLY) { - hashp->errno = errno = EPERM; + hashp->errnum = errno = EPERM; return (ERROR); } return (hash_access(hashp, flag == R_NOOVERWRITE ? @@ -574,11 +574,11 @@ hash_delete(dbp, key, flag) hashp = (HTAB *)dbp->internal; if (flag && flag != R_CURSOR) { - hashp->errno = errno = EINVAL; + hashp->errnum = errno = EINVAL; return (ERROR); } if ((hashp->flags & O_ACCMODE) == O_RDONLY) { - hashp->errno = errno = EPERM; + hashp->errnum = errno = EPERM; return (ERROR); } return (hash_access(hashp, HASH_DELETE, (DBT *)key, NULL)); @@ -729,7 +729,7 @@ hash_seq(dbp, key, data, flag) hashp = (HTAB *)dbp->internal; if (flag && flag != R_FIRST && flag != R_NEXT) { - hashp->errno = errno = EINVAL; + hashp->errnum = errno = EINVAL; return (ERROR); } #ifdef HASH_STATISTICS diff --git a/db/hash/hash.h b/db/hash/hash.h index 913e82b..1c599c1 100644 --- a/db/hash/hash.h +++ b/db/hash/hash.h @@ -71,28 +71,28 @@ typedef struct hashhdr { /* Disk resident portion */ int dsize; /* Directory Size */ int ssize; /* Segment Size */ int sshift; /* Segment shift */ - int ovfl_point; /* Where overflow pages are being + int ovfl_point; /* Where overflow pages are being * allocated */ int last_freed; /* Last overflow page freed */ int max_bucket; /* ID of Maximum bucket in use */ int high_mask; /* Mask to modulo into entire table */ - int low_mask; /* Mask to modulo into lower half of + int low_mask; /* Mask to modulo into lower half of * table */ int ffactor; /* Fill factor */ int nkeys; /* Number of keys in hash table */ int hdrpages; /* Size of table header */ int h_charkey; /* value of hash(CHARKEY) */ -#define NCACHED 32 /* number of bit maps and spare +#define NCACHED 32 /* number of bit maps and spare * points */ int spares[NCACHED];/* spare pages for overflow */ - u_int16_t bitmaps[NCACHED]; /* address of overflow page + u_int16_t bitmaps[NCACHED]; /* address of overflow page * bitmaps */ } HASHHDR; typedef struct htab { /* Memory resident data structure */ HASHHDR hdr; /* Header */ int nsegs; /* Number of allocated segments */ - int exsegs; /* Number of extra allocated + int exsegs; /* Number of extra allocated * segments */ u_int32_t /* Hash function */ (*hash)__P((const void *, size_t)); @@ -103,16 +103,16 @@ typedef struct htab { /* Memory resident data structure */ BUFHEAD *cpage; /* Current page */ int cbucket; /* Current bucket */ int cndx; /* Index of next item on cpage */ - int errno; /* Error Number -- for DBM + int errnum; /* Error Number -- for DBM * compatability */ - int new_file; /* Indicates if fd is backing store + int new_file; /* Indicates if fd is backing store * or no */ - int save_file; /* Indicates whether we need to flush + int save_file; /* Indicates whether we need to flush * file at * exit */ u_int32_t *mapp[NCACHED]; /* Pointers to page maps */ int nmaps; /* Initial number of bitmaps */ - int nbufs; /* Number of buffers left to + int nbufs; /* Number of buffers left to * allocate */ BUFHEAD bufhead; /* Header of buffer lru list */ SEGMENT *dir; /* Hash Bucket directory */ @@ -194,7 +194,7 @@ typedef struct htab { /* Memory resident data structure */ * so it starts on this page and continues on the next. * The format of the page is: * KEY_OFF PARTIAL_KEY OVFL_PAGENO OVFLPAGE - * + * * KEY_OFF -- offset of the beginning of the key * PARTIAL_KEY -- 1 * OVFL_PAGENO - page number of the next overflow page @@ -229,7 +229,7 @@ typedef struct htab { /* Memory resident data structure */ * OVFL_PAGENO - page number of the next overflow page * OVFLPAGE -- 0 * - * FULL_KEY_DATA + * FULL_KEY_DATA * This must be the first key/data pair on the page. * There are two cases: * diff --git a/db/hash/ndbm.c b/db/hash/ndbm.c index 2cbbe91..83aa766 100644 --- a/db/hash/ndbm.c +++ b/db/hash/ndbm.c @@ -47,6 +47,7 @@ static char sccsid[] = "@(#)ndbm.c 8.4 (Berkeley) 7/21/94"; #include <stdio.h> #include <string.h> +#include <stdlib.h> #include <ndbm.h> #include "hash.h" @@ -61,8 +62,16 @@ dbm_open(file, flags, mode) const char *file; int flags, mode; { + DBM *db; HASHINFO info; - char path[MAXPATHLEN]; + const size_t len = strlen(file) + sizeof (DBM_SUFFIX); +#ifdef __GNUC__ + char path[len]; +#else + char *path = malloc(len); + if (path == NULL) + return NULL; +#endif info.bsize = 4096; info.ffactor = 40; @@ -72,7 +81,11 @@ 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, 0)); + db = (DBM *)__hash_open(path, flags, mode, &info, 0); +#ifndef __GNUC__ + free(path); +#endif + return db; } extern void @@ -180,7 +193,7 @@ dbm_error(db) HTAB *hp; hp = (HTAB *)db->internal; - return (hp->errno); + return (hp->errnum); } extern int @@ -190,7 +203,7 @@ dbm_clearerr(db) HTAB *hp; hp = (HTAB *)db->internal; - hp->errno = 0; + hp->errnum = 0; return (0); } |