]> git.saurik.com Git - apple/libc.git/blobdiff - db/btree/bt_overflow.c
Libc-320.tar.gz
[apple/libc.git] / db / btree / bt_overflow.c
index dc7394219ebd1f69b2cf2d320a82966b110775ce..489290e2d81abe88dd9f4db27480e4a4f3970bd8 100644 (file)
@@ -1,26 +1,29 @@
 /*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
-/*
- * Copyright (c) 1990, 1993
+/*-
+ * Copyright (c) 1990, 1993, 1994
  *     The Regents of the University of California.  All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
  * SUCH DAMAGE.
  */
 
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)bt_overflow.c      8.5 (Berkeley) 7/16/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
 
 #include <sys/param.h>
 
@@ -87,7 +94,7 @@
  *
  * Parameters:
  *     t:      tree
- *     p:      pointer to { pgno_t, size_t }
+ *     p:      pointer to { pgno_t, u_int32_t }
  *     buf:    storage address
  *     bufsz:  storage size
  *
@@ -99,15 +106,16 @@ __ovfl_get(t, p, ssz, buf, bufsz)
        BTREE *t;
        void *p;
        size_t *ssz;
-       char **buf;
+       void **buf;
        size_t *bufsz;
 {
        PAGE *h;
        pgno_t pg;
-       size_t nb, plen, sz;
+       size_t nb, plen;
+       u_int32_t sz;
 
        memmove(&pg, p, sizeof(pgno_t));
-       memmove(&sz, (char *)p + sizeof(pgno_t), sizeof(size_t));
+       memmove(&sz, (char *)p + sizeof(pgno_t), sizeof(u_int32_t));
        *ssz = sz;
 
 #ifdef DEBUG
@@ -116,7 +124,8 @@ __ovfl_get(t, p, ssz, buf, bufsz)
 #endif
        /* Make the buffer bigger as necessary. */
        if (*bufsz < sz) {
-               if ((*buf = (char *)realloc(*buf, sz)) == NULL)
+               *buf = (char *)(*buf == NULL ? malloc(sz) : reallocf(*buf, sz));
+               if (*buf == NULL)
                        return (RET_ERROR);
                *bufsz = sz;
        }
@@ -160,7 +169,8 @@ __ovfl_put(t, dbt, pg)
        PAGE *h, *last;
        void *p;
        pgno_t npg;
-       size_t nb, plen, sz;
+       size_t nb, plen;
+       u_int32_t sz;
 
        /*
         * Allocate pages and copy the key/data record into them.  Store the
@@ -199,7 +209,7 @@ __ovfl_put(t, dbt, pg)
  *
  * Parameters:
  *     t:      tree
- *     p:      pointer to { pgno_t, size_t }
+ *     p:      pointer to { pgno_t, u_int32_t }
  *
  * Returns:
  *     RET_ERROR, RET_SUCCESS
@@ -211,10 +221,11 @@ __ovfl_delete(t, p)
 {
        PAGE *h;
        pgno_t pg;
-       size_t plen, sz;
+       size_t plen;
+       u_int32_t sz;
 
        memmove(&pg, p, sizeof(pgno_t));
-       memmove(&sz, (char *)p + sizeof(pgno_t), sizeof(size_t));
+       memmove(&sz, (char *)p + sizeof(pgno_t), sizeof(u_int32_t));
 
 #ifdef DEBUG
        if (pg == P_INVALID || sz == 0)