home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #23 / NN_1992_23.iso / spool / vmsnet / internal / 1461 < prev    next >
Encoding:
Internet Message Format  |  1992-10-15  |  3.1 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: <01GPZBWYAOJ40001ZZ@esevvx.cica.es>
  6. Date: Thu, 15 Oct 1992 14:37:00 UTC+0100
  7. Organization: Macro32<==>Vmsnet.Internals Gateway
  8. X-Gateway-Source-Info: Mailing List
  9. Lines: 70
  10.  
  11. >X-Envelope-to: MACRO32@WKUVX1.bitnet
  12. >X-VMS-To: IN::"MACRO32@WKUVX1.BITNET"
  13.  
  14. 1
  15. 15-OCT-1992 00:56:08.90
  16.    1 00:00:00.00
  17. 16-OCT-1992 00:56:08.90
  18. @UKCC.uky.edu:MacroMan@WKUVX1.BITNET
  19. gutier@SEVAXU.CICA.ES
  20.  
  21. Received: from UKCC.uky.edu by ESEVVX.CICA.ES ; 12-OCT-1992 00:56:05.29
  22. Received: from ukcc.uky.edu by UKCC.uky.edu (IBM VM SMTP V2R2)
  23.    with BSMTP id 1387; Sun, 11 Oct 92 19:54:59 EDT
  24. Received: from WKUVX1.BITNET by ukcc.uky.edu (Mailer R2.08) with BSMTP id 8828;
  25.  Sun, 11 Oct 92 19:54:58 EDT
  26. Errors-To: MacroMan@WKUVX1.BITNET
  27. X-ListName: "VMS Internals, MACRO, and BLISS Discussions"
  28.     <MACRO32@WKUVX1.BITNET>
  29. Received: from CUNYVM.BITNET (MAILER) by WKUVX1 (MX V3.1C) with BSMTP; Sun, 11
  30.           Oct 1992 18:55:26 CDT
  31. Received: from CUNYVM by CUNYVM.BITNET (Mailer R2.08) with BSMTP id 1351; Sun,
  32.           11 Oct 92 19:52:19 EDT
  33. Received: from MVB.SAIC.COM by CUNYVM.CUNY.EDU (IBM VM SMTP V2R2) with TCP;
  34.           Sun, 11 Oct 92 19:52:07 EDT
  35. Relay-Version: VMS News - V6.0-3 14/03/90 VAX/VMS V5.5; site arizona.edu
  36.     darwin.sura.net!dtix!mimsy!prometheus!media!irscscm!bogart!aldoe!krm!mic!mon
  37. tag ar.com!davidc
  38. X-Newsgroups: vmsnet.internals,vmsnet.misc,comp.lang.c
  39. Subject: Re: malloc() as a user defined function
  40. Message-ID: <1992Oct9.233039.16829@montagar.com>
  41. From: <davidc@montagar.com>
  42. Reply-To: MACRO32@WKUVX1.BITNET
  43. Date: 9 Oct 92 23:30:38 GMT
  44. References: <Bvv6pH.Gzy@cs.psu.edu>
  45. Organization: Montagar Software Concepts, Plano TX
  46. Lines: 29
  47. Xref: arizona.edu vmsnet.internals:1492 vmsnet.misc:1305 comp.lang.c:27864
  48. To: MACRO32@WKUVX1.BITNET
  49. X-Gateway-Source-Info: USENET
  50.  
  51. In article <Bvv6pH.Gzy@cs.psu.edu>, ytang@red.crayola.cs.psu.edu (Yuan-Ling
  52.  Tang) writes:
  53. >
  54. > Hi netters:
  55. >
  56. >     In programming on dynamic memory allocation, I prefer doing check on
  57. >     every malloc(). I.e.:
  58. >     ...
  59. >     However another problem arises, what if I have many distinct types
  60. >     of memory space to allocate? That is, I can't use the same type in
  61. >     calling my_malloc(). So how can I pass a type to a function?
  62.  
  63.         Maybe something like this?
  64.  
  65. #define TALLOC(x)       {int p ; ((p = malloc(sizeof(x)) == NULL) ? \
  66.                                         {perror("Malloc") ; exit(errno) } : \
  67.                                         p ; }
  68.  
  69.         The sizeof() will resolve the type into the required number of bytes,
  70. such that
  71.  
  72.         bptr = TALLOC(struct bogus) ;
  73.  
  74.         will allocate the correct size buffer, while performing the check
  75. (I hope, I haven't tested that macro...)
  76.  
  77. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  78. David L. Cathey                         |INET: davidc@montagar.com
  79. Montagar Software Concepts              |UUCP: ...!montagar!davidc
  80. P. O. Box 260772, Plano TX  75026-0772  |Fone: (214)-618-2117
  81.