From: Adrian Wallaschek (Adrian.Wallaschek@arbi.informatik.uni-oldenburg.de)
Date: 11/18/92


From: Adrian.Wallaschek@arbi.informatik.uni-oldenburg.de (Adrian Wallaschek)
Subject: Severe problems with "realloc" (FIX_MALLOC)!
Date: Thu, 19 Nov 1992 00:21:28 GMT


Hi fellows!

I don't know wether I'm going to warm up forgotten discussions, but hasn't yet
anybody worked on a program that makes heavy use of realloc ?

I had severe problems getting a regex-package (0.11) to work. I got several
IOT-Trap-cores till I remebered about the malloc(0) problem with linux.
There is a work-around for malloc and calloc in stdlib.h BUT none for realloc!
Somebody forgot something, I suppose! ;-) So to avoid unnecessary cores you
might want to include few lines to your stdlib.h (to make it easy, lets
patch it!). Its nothing serious (just copied 5 lines) but it makes regex work!

I have found that even some library-functions make use of realloc, I think
this might be the cause of some porting-problems.

If this is a well known problem, please don't flame, I just wanted to help!

Prefect
(A.Wallaschek)

Any positive comments or further information or summaries on linux-bugs to:

Adrian.Wallaschek@ARBI.Informatik.Uni-Oldenburg.DE

AND FINALLY HERE IS the patch that normally wouldn't be worth it:

*** stdlib.h~ Mon Sep 7 20:08:19 1992
--- stdlib.h Thu Nov 19 00:52:18 1992
***************
*** 178,185 ****
--- 178,191 ----
    return malloc (__n ? __n : 1);
  }
  
+ static __inline__ void* __gnu_realloc (void * __p, size_t __n)
+ {
+ return realloc (__p, __n ? __n : 1);
+ }
+
  #define calloc(nmemb,n) __gnu_calloc((nmemb),(n))
  #define malloc(n) __gnu_malloc((n))
+ #define realloc(p,n) __gnu_realloc((p),(n))
  #endif
  
  #if defined(__USE_GNU) || defined(__USE_BSD) || defined(__USE_MISC)