home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / os / linux / 17160 < prev    next >
Encoding:
Text File  |  1992-11-18  |  2.0 KB  |  60 lines

  1. Newsgroups: comp.os.linux
  2. Path: sparky!uunet!sun-barr!cs.utexas.edu!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!ira.uka.de!math.fu-berlin.de!uniol!Adrian.Wallaschek
  3. From: Adrian.Wallaschek@arbi.informatik.uni-oldenburg.de (Adrian Wallaschek)
  4. Subject: Severe problems with "realloc" (FIX_MALLOC)!
  5. Organization: University of Oldenburg, Germany
  6. Date: Thu, 19 Nov 1992 00:21:28 GMT
  7. Message-ID: <1992Nov19.004235.9239@arbi.Informatik.Uni-Oldenburg.DE>
  8. Keywords: linux realloc bug malloc
  9. Sender: news@arbi.Informatik.Uni-Oldenburg.DE
  10. Lines: 48
  11.  
  12.  
  13. Hi fellows!
  14.  
  15. I don't know wether I'm going to warm up forgotten discussions, but hasn't yet
  16. anybody worked on a program that makes heavy use of realloc ?
  17.  
  18. I had severe problems getting a regex-package (0.11) to work. I got several
  19. IOT-Trap-cores till I remebered about the malloc(0) problem with linux.
  20. There is a work-around for malloc and calloc in stdlib.h BUT none for realloc!
  21. Somebody forgot something, I suppose! ;-) So to avoid unnecessary cores you
  22. might want to include few lines to your stdlib.h (to make it easy, lets 
  23. patch it!). Its nothing serious (just copied 5 lines) but it makes regex work!
  24.  
  25. I have found that even some library-functions make use of realloc, I think
  26. this might be the cause of some porting-problems.
  27.  
  28. If this is a well known problem, please don't flame, I just wanted to help!
  29.  
  30. Prefect
  31. (A.Wallaschek)
  32.  
  33. Any positive comments or further information or summaries on linux-bugs to:
  34.  
  35. Adrian.Wallaschek@ARBI.Informatik.Uni-Oldenburg.DE
  36.  
  37.  
  38.  
  39. AND FINALLY HERE IS the patch that normally wouldn't be worth it:
  40.  
  41. *** stdlib.h~    Mon Sep  7 20:08:19 1992
  42. --- stdlib.h    Thu Nov 19 00:52:18 1992
  43. ***************
  44. *** 178,185 ****
  45. --- 178,191 ----
  46.     return malloc (__n ? __n : 1);
  47.   }
  48.   
  49. + static __inline__ void* __gnu_realloc (void * __p, size_t __n)
  50. + {
  51. +   return realloc (__p, __n ? __n : 1);
  52. + }
  53.   #define calloc(nmemb,n)    __gnu_calloc((nmemb),(n))
  54.   #define malloc(n)    __gnu_malloc((n))
  55. + #define realloc(p,n)    __gnu_realloc((p),(n))
  56.   #endif
  57.   
  58.   #if defined(__USE_GNU) || defined(__USE_BSD) || defined(__USE_MISC)
  59.