diff options
Diffstat (limited to 'dbm/src')
-rw-r--r-- | dbm/src/h_bigkey.c | 10 | ||||
-rw-r--r-- | dbm/src/h_page.c | 21 | ||||
-rw-r--r-- | dbm/src/hash.c | 30 | ||||
-rw-r--r-- | dbm/src/hash_buf.c | 4 | ||||
-rw-r--r-- | dbm/src/nsres.c | 2 |
5 files changed, 36 insertions, 31 deletions
diff --git a/dbm/src/h_bigkey.c b/dbm/src/h_bigkey.c index b482f440c..07c2f98ed 100644 --- a/dbm/src/h_bigkey.c +++ b/dbm/src/h_bigkey.c @@ -472,7 +472,7 @@ collect_data( totlen = len + mylen; if (hashp->tmp_buf) free(hashp->tmp_buf); - if ((hashp->tmp_buf = (char *)malloc(totlen)) == NULL) + if ((hashp->tmp_buf = (char *)malloc((size_t)totlen)) == NULL) return (-1); if (set) { hashp->cndx = 1; @@ -500,7 +500,7 @@ collect_data( errno = EINVAL; /* Out of buffers. */ return (-1); } - memmove(&hashp->tmp_buf[len], (bufp->page) + bp[1], mylen); + memmove(&hashp->tmp_buf[len], (bufp->page) + bp[1], (size_t)mylen); return (totlen); } @@ -547,7 +547,7 @@ collect_key( if (bp[2] == FULL_KEY || bp[2] == FULL_KEY_DATA) { /* End of Key. */ if (hashp->tmp_key != NULL) free(hashp->tmp_key); - if ((hashp->tmp_key = (char *)malloc(totlen)) == NULL) + if ((hashp->tmp_key = (char *)malloc((size_t)totlen)) == NULL) return (-1); if (__big_return(hashp, bufp, 1, val, set)) return (-1); @@ -561,7 +561,7 @@ collect_key( errno = EINVAL; /* MIS -- OUT OF BUFFERS */ return (-1); } - memmove(&hashp->tmp_key[len], (bufp->page) + bp[1], mylen); + memmove(&hashp->tmp_key[len], (bufp->page) + bp[1], (size_t)mylen); return (totlen); } @@ -577,7 +577,7 @@ __big_split( BUFHEAD *np, /* Pointer to new bucket page */ /* Pointer to first page containing the big key/data */ BUFHEAD *big_keyp, - int addr, /* Address of big_keyp */ + uint32 addr, /* Address of big_keyp */ uint32 obucket,/* Old Bucket */ SPLIT_RETURN *ret) { diff --git a/dbm/src/h_page.c b/dbm/src/h_page.c index fbbf6d88d..e9b33f26c 100644 --- a/dbm/src/h_page.c +++ b/dbm/src/h_page.c @@ -159,7 +159,7 @@ long new_lseek(int fd, long offset, int origin) memset(&buffer, 0, 1024); while(len > 0) { - write(fd, (char*)&buffer, (1024 > len ? len : 1024)); + write(fd, (char*)&buffer, (size_t)(1024 > len ? len : 1024)); len -= 1024; } return(lseek(fd, seek_pos, SEEK_SET)); @@ -285,7 +285,8 @@ __split_page(HTAB *hashp, uint32 obucket, uint32 nbucket) DBT key, val; uint16 n, ndx; int retval; - uint16 copyto, diff, off, moved; + uint16 copyto, diff, moved; + size_t off; char *op; copyto = (uint16)hashp->BSIZE; @@ -684,8 +685,9 @@ __get_page(HTAB *hashp, int is_disk, int is_bitmap) { - register int fd, page, size; - int rsize; + register int fd, page; + size_t size; + ssize_t rsize; uint16 *bp; fd = hashp->fp; @@ -819,8 +821,9 @@ __get_page(HTAB *hashp, extern int __put_page(HTAB *hashp, char *p, uint32 bucket, int is_bucket, int is_bitmap) { - register int fd, page, size; - int wsize; + register int fd, page; + size_t size; + ssize_t wsize; size = hashp->BSIZE; if ((hashp->fp == -1) && open_temp(hashp)) @@ -904,9 +907,9 @@ extern int __ibitmap(HTAB *hashp, int pnum, int nbits, int ndx) { uint32 *ip; - int clearbytes, clearints; + size_t clearbytes, clearints; - if ((ip = (uint32 *)malloc(hashp->BSIZE)) == NULL) + if ((ip = (uint32 *)malloc((size_t)hashp->BSIZE)) == NULL) return (1); hashp->nmaps++; clearints = ((nbits - 1) >> INT_BYTE_SHIFT) + 1; @@ -1201,7 +1204,7 @@ fetch_bitmap(HTAB *hashp, uint32 ndx) { if (ndx >= hashp->nmaps) return (NULL); - if ((hashp->mapp[ndx] = (uint32 *)malloc(hashp->BSIZE)) == NULL) + if ((hashp->mapp[ndx] = (uint32 *)malloc((size_t)hashp->BSIZE)) == NULL) return (NULL); if (__get_page(hashp, (char *)hashp->mapp[ndx], hashp->BITMAPS[ndx], 0, 1, 1)) { diff --git a/dbm/src/hash.c b/dbm/src/hash.c index b6b7d70ee..267ac0618 100644 --- a/dbm/src/hash.c +++ b/dbm/src/hash.c @@ -81,7 +81,7 @@ static int hash_delete __P((const DB *, const DBT *, uint)); static int hash_fd __P((const DB *)); static int hash_get __P((const DB *, const DBT *, DBT *, uint)); static int hash_put __P((const DB *, DBT *, const DBT *, uint)); -static void *hash_realloc __P((SEGMENT **, int, int)); +static void *hash_realloc __P((SEGMENT **, size_t, size_t)); static int hash_seq __P((const DB *, DBT *, DBT *, uint)); static int hash_sync __P((const DB *, uint)); static int hdestroy __P((HTAB *)); @@ -424,7 +424,7 @@ init_hash(HTAB *hashp, const char *file, HASHINFO *info) if (hashp->BSIZE > MAX_BSIZE) hashp->BSIZE = MAX_BSIZE; #endif - hashp->BSHIFT = __log2(hashp->BSIZE); + hashp->BSHIFT = __log2((uint32)hashp->BSIZE); } if (info) { @@ -477,7 +477,7 @@ init_htab(HTAB *hashp, int nelem) */ nelem = (nelem - 1) / hashp->FFACTOR + 1; - l2 = __log2(MAX(nelem, 2)); + l2 = __log2((uint32)MAX(nelem, 2)); nbuckets = 1 << l2; hashp->SPARES[l2] = l2 + 1; @@ -486,7 +486,7 @@ init_htab(HTAB *hashp, int nelem) hashp->LAST_FREED = 2; /* First bitmap page is at: splitpoint l2 page offset 1 */ - if (__ibitmap(hashp, OADDR_OF(l2, 1), l2 + 1, 0)) + if (__ibitmap(hashp, (int)OADDR_OF(l2, 1), l2 + 1, 0)) return (-1); hashp->MAX_BUCKET = hashp->LOW_MASK = nbuckets - 1; @@ -495,7 +495,7 @@ init_htab(HTAB *hashp, int nelem) hashp->BSHIFT) + 1; nsegs = (nbuckets - 1) / hashp->SGSIZE + 1; - nsegs = 1 << __log2(nsegs); + nsegs = 1 << __log2((uint32)nsegs); if (nsegs > hashp->DSIZE) hashp->DSIZE = nsegs; @@ -763,7 +763,8 @@ hash_access( register BUFHEAD *rbufp; BUFHEAD *bufp, *save_bufp; register uint16 *bp; - register long n, ndx, off, size; + register long n, ndx, off; + register size_t size; register char *kp; uint16 pageno; uint32 ovfl_loop_count=0; @@ -822,7 +823,7 @@ hash_access( off = hashp->BSIZE; } else if (bp[1] < REAL_KEY) { if ((ndx = - __find_bigpair(hashp, rbufp, ndx, kp, size)) > 0) + __find_bigpair(hashp, rbufp, ndx, kp, (int)size)) > 0) goto found; if (ndx == -2) { bufp = rbufp; @@ -998,7 +999,8 @@ extern int __expand_table(HTAB *hashp) { uint32 old_bucket, new_bucket; - int dirsize, new_segnum, spare_ndx; + int new_segnum, spare_ndx; + size_t dirsize; #ifdef HASH_STATISTICS hash_expansions++; @@ -1019,7 +1021,7 @@ __expand_table(HTAB *hashp) hashp->DSIZE = dirsize << 1; } if ((hashp->dir[new_segnum] = - (SEGMENT)calloc(hashp->SGSIZE, sizeof(SEGMENT))) == NULL) + (SEGMENT)calloc((size_t)hashp->SGSIZE, sizeof(SEGMENT))) == NULL) return (-1); hashp->exsegs++; hashp->nsegs++; @@ -1029,7 +1031,7 @@ __expand_table(HTAB *hashp) * * increases), we need to copy the current contents of the spare * split bucket to the next bucket. */ - spare_ndx = __log2(hashp->MAX_BUCKET + 1); + spare_ndx = __log2((uint32)(hashp->MAX_BUCKET + 1)); if (spare_ndx > hashp->OVFL_POINT) { hashp->SPARES[spare_ndx] = hashp->SPARES[hashp->OVFL_POINT]; hashp->OVFL_POINT = spare_ndx; @@ -1051,7 +1053,7 @@ __expand_table(HTAB *hashp) static void * hash_realloc( SEGMENT **p_ptr, - int oldsize, int newsize) + size_t oldsize, size_t newsize) { register void *p; @@ -1065,7 +1067,7 @@ hash_realloc( } extern uint32 -__call_hash(HTAB *hashp, char *k, int len) +__call_hash(HTAB *hashp, char *k, size_t len) { uint32 n, bucket; @@ -1092,7 +1094,7 @@ alloc_segs( int save_errno; if ((hashp->dir = - (SEGMENT *)calloc(hashp->DSIZE, sizeof(SEGMENT *))) == NULL) { + (SEGMENT *)calloc((size_t)hashp->DSIZE, sizeof(SEGMENT *))) == NULL) { save_errno = errno; (void)hdestroy(hashp); errno = save_errno; @@ -1100,7 +1102,7 @@ alloc_segs( } /* Allocate segments */ if ((store = - (SEGMENT)calloc(nsegs << hashp->SSHIFT, sizeof(SEGMENT))) == NULL) { + (SEGMENT)calloc((size_t)nsegs << hashp->SSHIFT, sizeof(SEGMENT))) == NULL) { save_errno = errno; (void)hdestroy(hashp); errno = save_errno; diff --git a/dbm/src/hash_buf.c b/dbm/src/hash_buf.c index f30bee32e..35968601b 100644 --- a/dbm/src/hash_buf.c +++ b/dbm/src/hash_buf.c @@ -216,7 +216,7 @@ newbuf(HTAB *hashp, uint32 addr, BUFHEAD *prev_bp) */ memset(bp, 0xff, sizeof(BUFHEAD)); - if ((bp->page = (char *)malloc(hashp->BSIZE)) == NULL) { + if ((bp->page = (char *)malloc((size_t)hashp->BSIZE)) == NULL) { free(bp); return (NULL); } @@ -224,7 +224,7 @@ newbuf(HTAB *hashp, uint32 addr, BUFHEAD *prev_bp) /* this memset is supposedly unnecessary but lets add * it anyways. */ - memset(bp->page, 0xff, hashp->BSIZE); + memset(bp->page, 0xff, (size_t)hashp->BSIZE); if (hashp->nbufs) hashp->nbufs--; diff --git a/dbm/src/nsres.c b/dbm/src/nsres.c index 1751b7c08..44b448cf7 100644 --- a/dbm/src/nsres.c +++ b/dbm/src/nsres.c @@ -49,7 +49,7 @@ int GenKeyData(const char *library, int32 id, DBT *key) { char idstr[10]; static char * strdata = NULL; - int len; + size_t len; if (strdata) free (strdata); |