[comp.lang.perl] unofficial malloc.c patch

vinoski@apollo.HP.COM (Stephen Vinoski) (04/19/91)

After applying the new patches for Perl 4.0 I still had trouble
building on my Apollo DN3500 using cc 6.8.  The ANSI C compiler
doesn't like the function parameter mismatches for free() and
realloc().  I suspect other systems will have the same problem, so I
have included an unofficial patch to correct the problem.

Also, Configure incorrectly guessed that our malloc() returns char *
when it really returns void *.  Nothing my editor couldn't fix,
though.


-steve


*** malloc.c.broken	Thu Apr 18 14:26:47 1991
--- malloc.c	Thu Apr 18 14:28:31 1991
***************
*** 108,115 ****
--- 108,119 ----
  #endif
  
  MALLOCPTRTYPE *
+ #ifdef __STDC__
+ malloc(size_t nbytes)
+ #else
  malloc(nbytes)
  	register unsigned nbytes;
+ #endif
  {
    	register union overhead *p;
    	register int bucket = 0;
***************
*** 230,237 ****
--- 234,245 ----
  }
  
  void
+ #ifdef __STDC__
+ free(void *cp)
+ #else
  free(cp)
  	char *cp;
+ #endif
  {   
    	register int size;
  	register union overhead *op;
***************
*** 277,285 ****
--- 285,297 ----
  int reall_srchlen = 4;	/* 4 should be plenty, -1 =>'s whole list */
  
  MALLOCPTRTYPE *
+ #ifdef __STDC__
+ realloc(void *cp, size_t nbytes)
+ #else
  realloc(cp, nbytes)
  	char *cp; 
  	unsigned nbytes;
+ #endif
  {   
    	register u_int onb;
  	union overhead *op;
| Steve Vinoski  (508)256-0176 x5904       | Internet: vinoski@apollo.hp.com  |
| HP Apollo Division, Chelmsford, MA 01824 | UUCP: ...!apollo!vinoski         |
| "The price of knowledge is learning how little of it you yourself harbor."  |
|                                                    - Tom Christiansen       |