home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / os2 / programm / 4326 < prev    next >
Encoding:
Internet Message Format  |  1992-08-19  |  1.9 KB

  1. Xref: sparky comp.os.os2.programmer:4326 comp.lang.c:12530
  2. Newsgroups: comp.os.os2.programmer,comp.lang.c
  3. Path: sparky!uunet!ukma!darwin.sura.net!convex!news.utdallas.edu!corpgate!crchh327!davisonj
  4. From: davisonj@bnr.ca (John Davison)
  5. Subject: Re: malloc causes a segmentation violation!?
  6. Message-ID: <1992Aug19.171317.9312@bnr.ca>
  7. Summary: just another plug for user-defined heap management
  8. Sender: news@bnr.ca (News on crchh327)
  9. Nntp-Posting-Host: crchh7ab
  10. Organization: Bell-Northern Research, Richardson, Tx.
  11. References: <1992Aug18.143135.6259@cc.tut.fi> <3dfy6bq@rpi.edu> <1992Aug19.155648.6210@funet.fi>
  12. Date: Wed, 19 Aug 1992 17:13:17 GMT
  13. Lines: 23
  14.  
  15. In article <1992Aug19.155648.6210@funet.fi> mn87504@cs.tut.fi (Naatula Mika) writes:
  16. >I made my own Smalloc and and Sfree functions which call the standard
  17. >malloc and free. I save in a table the allocated pointers and compare them
  18. >before free is called. This is an easy way to catch many possible errors.
  19.  
  20.         For what it's worth, I got burned by getting internal errors in
  21. malloc() and free(), then finding out that the reason for those errors was that
  22. I was walking over memory that wasn't mine.  That experience made me a firm
  23. believer in user-defined heap management, even if it is something as simple as
  24. jacket routines (or macros) which control malloc and free.
  25.  
  26.         The fact that the C spec permits implementations to provide a malloc
  27. that returns only NULL is another compelling reason for the programmer not to
  28. rely on directly calling malloc or free.
  29.  
  30.         For portability and robustness, DON'T DIRECTLY USE malloc!
  31.  
  32.  
  33. -- 
  34. NOTE: I CAN'T SEND/RECEIVE E-MAIL HERE!!!  Use --> davisonj@ecn.purdue.edu <--
  35.       During (roughly) August 20-25, I will be in transit.  Please be patient.
  36.       The opinions and other information contained herein are not necessarily
  37.       representative of Northern Telecom or any of its subsidiaries. 
  38.