home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #23 / NN_1992_23.iso / spool / vmsnet / internal / 1460 < prev    next >
Encoding:
Internet Message Format  |  1992-10-15  |  3.2 KB

  1. Path: sparky!uunet!stanford.edu!agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!news.service.uci.edu!unogate!mvb.saic.com!macro32
  2. From: REGI's <NUNEZ@esevvx.cica.es>
  3. Newsgroups: vmsnet.internals
  4. Subject: (None)
  5. Message-ID: <01GPZDUYXRZ40001ZZ@esevvx.cica.es>
  6. Date: Thu, 15 Oct 1992 15:32:00 UTC+0100
  7. Organization: Macro32<==>Vmsnet.Internals Gateway
  8. X-Gateway-Source-Info: Mailing List
  9. Lines: 80
  10.  
  11. >X-Envelope-to: macro32@WKUVX1.bitnet
  12. >X-VMS-To: IN::"macro32@WKUVX1.BITNET"
  13.  
  14. 1
  15. 14-OCT-1992 00:51:51.01
  16.    1 00:00:00.00
  17. 15-OCT-1992 00:51:51.01
  18. @UKCC.uky.edu:MacroMan@WKUVX1.BITNET
  19. gutier@SEVAXU.CICA.ES
  20.  
  21. Received: from UKCC.uky.edu by ESEVVX.CICA.ES ; 11-OCT-1992 00:51:48.32
  22. Received: from ukcc.uky.edu by UKCC.uky.edu (IBM VM SMTP V2R2)
  23.    with BSMTP id 9449; Sat, 10 Oct 92 19:50:42 EDT
  24. Received: from WKUVX1.BITNET by ukcc.uky.edu (Mailer R2.08) with BSMTP id 2626;
  25.  Sat, 10 Oct 92 19:50:40 EDT
  26. Errors-To: MacroMan@WKUVX1.BITNET
  27. X-ListName: "VMS Internals, MACRO, and BLISS Discussions"
  28.     <MACRO32@WKUVX1.BITNET>
  29. Received: from UGA.CC.UGA.EDU (MAILER) by WKUVX1 (MX V3.1C) with BSMTP; Sat, 10
  30.           Oct 1992 18:10:58 CDT
  31. Received: from UGA by UGA.CC.UGA.EDU (Mailer R2.08 PTF008) with BSMTP id 0872;
  32.           Sat, 10 Oct 92 12:23:08 EDT
  33. Received: from inet-gw-2.pa.dec.com by uga.cc.uga.edu (IBM VM SMTP V2R2) with
  34.           TCP; Sat, 10 Oct 92 12:23:07 EDT
  35. Received: by inet-gw-2.pa.dec.com; id AA08167; Sat, 10 Oct 92 09:24:02 -0700
  36. Received: by vbormc.vbo.dec.com; id AA20403; Sat, 10 Oct 92 17:19:11 +0100
  37. Message-ID: <9210101619.AA20403@vbormc.vbo.dec.com>
  38. Received: from taveng.enet; by vbormc.enet; Sat, 10 Oct 92 17:19:17 MET
  39. Date: Sat, 10 Oct 92 17:19:17 MET
  40. X-MX-Warning:   Warning -- Invalid "From" header.
  41. From: Yaacov Fenster @ISO 882-3153  10-Oct-1992 1823
  42.       <fenster@taveng.enet.dec.com>
  43. Reply-To: MACRO32@WKUVX1.BITNET
  44. To: macro32@WKUVX1.BITNET
  45. CC: fenster@taveng.enet.dec.com
  46. Apparently-To: macro32@wkuvx1.bitnet
  47. Subject: RE: malloc() as a user defined function
  48.  
  49. > From: VBORMC::"MACRO32@WKUVX1.BITNET" "MAIL-11 Daemon"  9-OCT-1992 21:28:56.38
  50. > To:   MACRO32@WKUVX1.BITNET
  51. > CC:
  52. > Subj: malloc() as a user defined function
  53. >
  54. >
  55. > Hi netters:
  56. >
  57. >     In programming on dynamic memory allocation, I prefer doing check on
  58. >     every malloc(). I.e.:
  59. >
  60. >     if ((p=(SOME_TYPE *)malloc(sizeof(SOME_TYPE))) == NULL) {
  61. >         printf("Malloc error.\n");
  62. >         exit(0);
  63. >     }
  64. >
  65. >     It turned out it's a pain to type in the above four lines if I have
  66. >     lots of malloc() invocations in the program, also, the program looks
  67. >     ugly. So I tried to use a function called my_malloc():
  68. >
  69. >     SOME_TYPE *my_malloc()
  70. >     {
  71. >         SOME_TYPE *p;
  72. >
  73. >         if ((p=(SOME_TYPE *)malloc(sizeof(SOME_TYPE))) == NULL) {
  74. >             printf("Malloc error.\n");
  75. >             exit(0);
  76. >         }
  77. >         return(p);
  78. >     }
  79. >
  80. Try my_malloc() returning type of "void *", this will convert into any "type *"
  81. type.
  82.  
  83.         Yaacov
  84.  
  85. -------------------------------------------------
  86. Yaacov Fenster                  +(972)-3-9307239
  87. y.fenster@ieee.org
  88. fenster@taveng.enet.dec.com     DTN 882-3153
  89. All the opinions voiced are mine alone and do not reflect anyone else's
  90. opinion. (Including Dec).
  91.