Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixup commit for tag 'DBM_1_61_RC1'
  • Loading branch information
cvs2hg committed Mar 23, 2002
1 parent acaf5e7 commit 0530967
Show file tree
Hide file tree
Showing 1,408 changed files with 90 additions and 599,652 deletions.
10 changes: 6 additions & 4 deletions dbm/include/mcom_db.h
Expand Up @@ -174,14 +174,10 @@
#endif

#ifdef __QNX__
#ifdef __QNXNTO__
#include <sys/param.h>
#else
#define LITTLE_ENDIAN 1234
#define BIG_ENDIAN 4321
#define BYTE_ORDER LITTLE_ENDIAN
#endif
#endif

#ifdef SNI
/* #include <sys/hetero.h> */
Expand Down Expand Up @@ -212,14 +208,20 @@
#define MAXPATHLEN 1024
#endif

#ifdef macintosh
#include <unix.h>
#else
#include <fcntl.h>
#endif

#if defined(_WINDOWS) || defined(XP_OS2)
#include <stdio.h>
#include <io.h>

#ifndef XP_OS2
#define MAXPATHLEN 1024
#else
#include <dirent.h>
#endif

#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */
Expand Down
Binary file added dbm/macbuild/DBM.mcp
Binary file not shown.
4,326 changes: 0 additions & 4,326 deletions dbm/macbuild/DBM.xml

This file was deleted.

12 changes: 2 additions & 10 deletions dbm/src/Makefile.in
Expand Up @@ -29,10 +29,6 @@ include $(DEPTH)/config/autoconf.mk
LIBRARY_NAME = mozdbm_s
LIB_IS_C_ONLY = 1

ifeq ($(OS_ARCH),WINNT)
LIBRARY_NAME = dbm$(MOZ_BITS)
endif

CSRCS = \
db.c \
h_bigkey.c \
Expand All @@ -48,17 +44,13 @@ CSRCS = \
nsres.c \
$(NULL)

ifeq ($(OS_ARCH),WINNT)
CSRCS += memmove.c snprintf.c
else
ifeq (,$(filter -DHAVE_MEMMOVE=1,$(DEFS)))
CSRCS += memmove.c
CSRC += memmove.c
endif

ifeq (,$(filter -DHAVE_SNPRINTF=1,$(DEFS)))
CSRCS += snprintf.c
CSRC += snprintf.c
endif
endif # WINNT

LOCAL_INCLUDES = -I$(srcdir)/../include

Expand Down
116 changes: 74 additions & 42 deletions dbm/src/h_bigkey.c
Expand Up @@ -364,6 +364,7 @@ __big_return(
BUFHEAD *save_p;
uint16 *bp, len, off, save_addr;
char *tp;
char save_flags;

bp = (uint16 *)bufp->page;
while (bp[ndx + 1] == PARTIAL_KEY) {
Expand Down Expand Up @@ -428,7 +429,12 @@ __big_return(
return (0);
}

/* pin our saved buf so that we don't lose if
* we run out of buffers */
save_flags = save_p->flags;
save_p->flags |= BUF_PIN;
val->size = collect_data(hashp, bufp, (int)len, set_current);
save_p->flags = save_flags;
if (val->size == (size_t)-1)
return (-1);
if (save_p->addr != save_addr) {
Expand All @@ -440,9 +446,14 @@ __big_return(
val->data = (uint8 *)hashp->tmp_buf;
return (0);
}


/*
* Count how big the total datasize is by recursing through the pages. Then
* allocate a buffer and copy the data as you recurse up.
* Count how big the total datasize is by looping through the pages. Then
* allocate a buffer and copy the data in the second loop. NOTE: Our caller
* may already have a bp which it is holding onto. The caller is
* responsible for copying that bp into our temp buffer. 'len' is how much
* space to reserve for that buffer.
*/
static int
collect_data(
Expand All @@ -451,56 +462,77 @@ collect_data(
int len, int set)
{
register uint16 *bp;
register char *p;
BUFHEAD *xbp;
uint16 save_addr;
BUFHEAD *save_bufp;
char save_flags;
int mylen, totlen;

p = bufp->page;
bp = (uint16 *)p;
mylen = hashp->BSIZE - bp[1];

/* if mylen ever goes negative it means that the
* page is screwed up.
/*
* save the input buf head because we need to walk the list twice.
* pin it to make sure it doesn't leave the buffer pool.
* This has the effect of growing the buffer pool if necessary.
*/
if(mylen < 0)
save_bufp = bufp;
save_flags = save_bufp->flags;
save_bufp->flags |= BUF_PIN;

/* read the length of the buffer */
for (totlen = len; bufp ; bufp = __get_buf(hashp, bp[bp[0]-1], bufp, 0)) {
bp = (uint16 *)bufp->page;
mylen = hashp->BSIZE - bp[1];
if (mylen < 0) {
save_bufp->flags = save_flags;
return (-1);
}
totlen += mylen;
if (bp[2] == FULL_KEY_DATA) {
break;
}
}

if (!bufp) {
save_bufp->flags = save_flags;
return (-1);
}

save_addr = bufp->addr;
/* allocate a temp buf */
if (hashp->tmp_buf)
free(hashp->tmp_buf);
if ((hashp->tmp_buf = (char *)malloc((size_t)totlen)) == NULL) {
save_bufp->flags = save_flags;
return (-1);
}

if (bp[2] == FULL_KEY_DATA) { /* End of Data */
totlen = len + mylen;
if (hashp->tmp_buf)
free(hashp->tmp_buf);
if ((hashp->tmp_buf = (char *)malloc((size_t)totlen)) == NULL)
return (-1);
if (set) {
hashp->cndx = 1;
if (bp[0] == 2) { /* No more buckets in chain */
hashp->cpage = NULL;
/* copy the buffers back into temp buf */
for (bufp = save_bufp; bufp ;
bufp = __get_buf(hashp, bp[bp[0]-1], bufp, 0)) {
bp = (uint16 *)bufp->page;
mylen = hashp->BSIZE - bp[1];
memmove(&hashp->tmp_buf[len], (bufp->page) + bp[1], (size_t)mylen);
len += mylen;
if (bp[2] == FULL_KEY_DATA) {
break;
}
}

/* 'clear' the pin flags */
save_bufp->flags = save_flags;

/* update the database cursor */
if (set) {
hashp->cndx = 1;
if (bp[0] == 2) { /* No more buckets in chain */
hashp->cpage = NULL;
hashp->cbucket++;
} else {
hashp->cpage = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!hashp->cpage)
return (-1);
else if (!((uint16 *)hashp->cpage->page)[0]) {
hashp->cbucket++;
} else {
hashp->cpage =
__get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!hashp->cpage)
return (-1);
else if (!((uint16 *)hashp->cpage->page)[0]) {
hashp->cbucket++;
hashp->cpage = NULL;
}
hashp->cpage = NULL;
}
}
} else {
xbp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!xbp || ((totlen =
collect_data(hashp, xbp, len + mylen, set)) < 1))
return (-1);
}
if (bufp->addr != save_addr) {
errno = EINVAL; /* Out of buffers. */
return (-1);
}
memmove(&hashp->tmp_buf[len], (bufp->page) + bp[1], (size_t)mylen);
return (totlen);
}

Expand Down
4 changes: 2 additions & 2 deletions dbm/src/hash.c
Expand Up @@ -419,8 +419,8 @@ init_hash(HTAB *hashp, const char *file, HASHINFO *info)
return (NULL);

#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh) && !defined(VMS) && !defined(XP_OS2)
#if defined(__QNX__) && !defined(__QNXNTO__)
hashp->BSIZE = 512; /* preferred blk size on qnx4 */
#ifdef __QNX__
hashp->BSIZE = statbuf.st_size;
#else
hashp->BSIZE = statbuf.st_blksize;
#endif
Expand Down
6 changes: 6 additions & 0 deletions dbm/src/hash_buf.c
Expand Up @@ -284,6 +284,12 @@ newbuf(HTAB *hashp, uint32 addr, BUFHEAD *prev_bp)
xbp->ovfl = 0;
xbp = next_xbp;

/* leave pinned pages alone, we are still using
* them. */
if (xbp->flags & BUF_PIN) {
continue;
}

/* Check that ovfl pointer is up date. */
if (IS_BUCKET(xbp->flags) ||
(oaddr != xbp->addr))
Expand Down
4 changes: 0 additions & 4 deletions dbm/src/ndbm.c
Expand Up @@ -52,10 +52,6 @@ static char sccsid[] = "@(#)ndbm.c 8.4 (Berkeley) 7/21/94";
#include <linux/limits.h>
#endif

#ifdef __OS2__
#include "dirent.h"
#endif

#include <stdio.h>
#include <string.h>

Expand Down
4 changes: 0 additions & 4 deletions dbm/tests/Makefile.in
Expand Up @@ -31,11 +31,7 @@ PROGRAM = lots$(BIN_SUFFIX)

CSRCS = lots.c

ifeq ($(OS_ARCH),WINNT)
EXTRA_DSO_LIBS = dbm$(MOZ_BITS)
else
EXTRA_DSO_LIBS = mozdbm_s
endif

LIBS = $(EXTRA_DSO_LIBS)

Expand Down

0 comments on commit 0530967

Please sign in to comment.