perl 4.0 patch 14: patch #11, continued
[p5sagit/p5-mst-13.2.git] / malloc.c
index 86fdb5c..72a265e 100644 (file)
--- a/malloc.c
+++ b/malloc.c
@@ -1,18 +1,14 @@
-/* $Header: malloc.c,v 3.0.1.3 90/10/16 15:27:47 lwall Locked $
+/* $RCSfile: malloc.c,v $$Revision: 4.0.1.2 $$Date: 91/06/07 11:20:45 $
  *
  * $Log:       malloc.c,v $
- * Revision 3.0.1.3  90/10/16  15:27:47  lwall
- * patch29: various portability fixes
+ * Revision 4.0.1.2  91/06/07  11:20:45  lwall
+ * patch4: many, many itty-bitty portability fixes
  * 
- * Revision 3.0.1.2  89/11/11  04:36:37  lwall
- * patch2: malloc pointer corruption check made more portable
+ * Revision 4.0.1.1  91/04/11  17:48:31  lwall
+ * patch1: Configure now figures out malloc ptr type
  * 
- * Revision 3.0.1.1  89/10/26  23:15:05  lwall
- * patch1: some declarations were missing from malloc.c
- * patch1: sparc machines had alignment problems in malloc.c
- * 
- * Revision 3.0  89/10/18  15:20:39  lwall
- * 3.0 baseline
+ * Revision 4.0  91/03/20  01:28:52  lwall
+ * 4.0 baseline.
  * 
  */
 
@@ -56,8 +52,8 @@ static findbucket(), morecore();
  */
 union  overhead {
        union   overhead *ov_next;      /* when free */
-#if defined(mips) || defined(sparc) || defined(luna88k)
-       double  strut;                  /* alignment problems */
+#if ALIGNBYTES > 4
+       double  strut;                  /* alignment problems */
 #endif
        struct {
                u_char  ovu_magic;      /* magic number */
@@ -114,7 +110,7 @@ botch(s)
 #define        ASSERT(p)
 #endif
 
-char *
+MALLOCPTRTYPE *
 malloc(nbytes)
        register unsigned nbytes;
 {
@@ -167,7 +163,7 @@ malloc(nbytes)
        p->ov_rmagic = RMAGIC;
        *((u_int *)((caddr_t)p + nbytes - RSLOP)) = RMAGIC;
 #endif
-       return ((char *)(p + 1));
+       return ((MALLOCPTRTYPE *)(p + 1));
 }
 
 /*
@@ -236,11 +232,13 @@ morecore(bucket)
        }
 }
 
-free(cp)
-       char *cp;
+void
+free(mp)
+       MALLOCPTRTYPE *mp;
 {   
        register int size;
        register union overhead *op;
+       char *cp = (char*)mp;
 
        if (cp == NULL)
                return;
@@ -282,9 +280,9 @@ free(cp)
  */
 int reall_srchlen = 4; /* 4 should be plenty, -1 =>'s whole list */
 
-char *
-realloc(cp, nbytes)
-       char *cp; 
+MALLOCPTRTYPE *
+realloc(mp, nbytes)
+       MALLOCPTRTYPE *mp; 
        unsigned nbytes;
 {   
        register u_int onb;
@@ -292,6 +290,7 @@ realloc(cp, nbytes)
        char *res;
        register int i;
        int was_alloced = 0;
+       char *cp = (char*)mp;
 
        if (cp == NULL)
                return (malloc(nbytes));
@@ -337,15 +336,15 @@ realloc(cp, nbytes)
                        *((u_int *)((caddr_t)op + nbytes - RSLOP)) = RMAGIC;
                }
 #endif
-               return(cp);
+               return((MALLOCPTRTYPE*)cp);
        }
-       if ((res = malloc(nbytes)) == NULL)
+       if ((res = (char*)malloc(nbytes)) == NULL)
                return (NULL);
        if (cp != res)                  /* common optimization */
                (void)bcopy(cp, res, (int)((nbytes < onb) ? nbytes : onb));
        if (was_alloced)
                free(cp);
-       return (res);
+       return ((MALLOCPTRTYPE*)res);
 }
 
 /*