home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / next / programm / 5854 < prev    next >
Encoding:
Text File  |  1992-08-29  |  1.5 KB  |  63 lines

  1. Path: sparky!uunet!sun-barr!sh.wide!wnoc-tyo-news!lkbreth!sgtp!shin
  2. From: shin@sgtp.apple.juice.or.jp (Sugou Shinichirou)
  3. Newsgroups: comp.sys.next.programmer
  4. Subject: malloc_error
  5. Message-ID: <SHIN.92Aug29190422@sgtp.sgtp.apple.juice.or.jp>
  6. Date: 29 Aug 92 10:04:22 GMT
  7. Sender: shin@sgtp.apple.juice.or.jp
  8. Distribution: comp
  9. Organization: SG Total Planning, Japan
  10. Lines: 51
  11.  
  12. Hello.
  13.  
  14. I don't know the way how to use 'malloc_error' function. Please refer to
  15. the UNIX manual 'malloc_error' about the detailed information.
  16.  
  17. Suppose I want to execute myMallocErr() instead of the default routine
  18. whenever memory allocation error happens.
  19.  
  20. void myMallocErr(int code)
  21. {
  22.         printf("error");
  23.         abort();
  24. }
  25.  
  26. How do I write the code? Following two trials failed:
  27.  
  28. (1)  malloc_error = myMallocErr      // compiler rejects
  29.  
  30. (2)  malloc_error(myMallocErr)      // not myMallocErr but default routine is called
  31.  
  32.  
  33. PS: If you are going to 'start' malloc-check-routine, following procedure
  34.     is one example:
  35. (1) Execute malloc_debug(level) in somewhere. For example:
  36.  
  37.         main()
  38.         {
  39.             malloc_debug(32);
  40.             ...
  41.             exit(0);
  42.         }
  43. (2) Link program with  '-lMallocDebug'. For example: If you are using IB,
  44.     define the following line within Makefile.preamble, and 'make debug'
  45.     will generate the malloc-check-routine active code.
  46.  
  47.     OTHER_DEBUG_LIBS = -lMallocDebug
  48.  
  49.  
  50. That all.
  51.  
  52. Thank you.
  53.  
  54. ---
  55. Shin'ichirou Sugou    (NeXTmail acceptable)
  56. --
  57. Shin'ichirou Sugou
  58.  
  59. shin@apple.juice.or.jp (NeXTmail acceptable)
  60.  
  61.  
  62.                    
  63.