Article View: vmsnet.internals
Article #387(None)
From: REGI's
Date: Thu, 15 Oct 1992 13:37
Date: Thu, 15 Oct 1992 13:37
70 lines
3297 bytes
3297 bytes
>X-Envelope-to: MACRO32@WKUVX1.bitnet
>X-VMS-To: IN::"MACRO32@WKUVX1.BITNET"
1
15-OCT-1992 00:56:08.90
1 00:00:00.00
16-OCT-1992 00:56:08.90
@UKCC.uky.edu:MacroMan@WKUVX1.BITNET
gutier@SEVAXU.CICA.ES
Received: from UKCC.uky.edu by ESEVVX.CICA.ES ; 12-OCT-1992 00:56:05.29
Received: from ukcc.uky.edu by UKCC.uky.edu (IBM VM SMTP V2R2)
with BSMTP id 1387; Sun, 11 Oct 92 19:54:59 EDT
Received: from WKUVX1.BITNET by ukcc.uky.edu (Mailer R2.08) with BSMTP id 8828;
Sun, 11 Oct 92 19:54:58 EDT
Errors-To: MacroMan@WKUVX1.BITNET
X-ListName: "VMS Internals, MACRO, and BLISS Discussions"
<MACRO32@WKUVX1.BITNET>
Received: from CUNYVM.BITNET (MAILER) by WKUVX1 (MX V3.1C) with BSMTP; Sun, 11
Oct 1992 18:55:26 CDT
Received: from CUNYVM by CUNYVM.BITNET (Mailer R2.08) with BSMTP id 1351; Sun,
11 Oct 92 19:52:19 EDT
Received: from MVB.SAIC.COM by CUNYVM.CUNY.EDU (IBM VM SMTP V2R2) with TCP;
Sun, 11 Oct 92 19:52:07 EDT
Relay-Version: VMS News - V6.0-3 14/03/90 VAX/VMS V5.5; site arizona.edu
darwin.sura.net!dtix!mimsy!prometheus!media!irscscm!bogart!aldoe!krm!mic!mon
tag ar.com!davidc
X-Newsgroups: vmsnet.internals,vmsnet.misc,comp.lang.c
Subject: Re: malloc() as a user defined function
Message-ID: <1992Oct9.233039.16829@montagar.com>
From: <davidc@montagar.com>
Reply-To: MACRO32@WKUVX1.BITNET
Date: 9 Oct 92 23:30:38 GMT
References: <Bvv6pH.Gzy@cs.psu.edu>
Organization: Montagar Software Concepts, Plano TX
Lines: 29
Xref: arizona.edu vmsnet.internals:1492 vmsnet.misc:1305 comp.lang.c:27864
To: MACRO32@WKUVX1.BITNET
X-Gateway-Source-Info: USENET
In article <Bvv6pH.Gzy@cs.psu.edu>, ytang@red.crayola.cs.psu.edu (Yuan-Ling
Tang) writes:
>
> Hi netters:
>
> In programming on dynamic memory allocation, I prefer doing check on
> every malloc(). I.e.:
> ...
> However another problem arises, what if I have many distinct types
> of memory space to allocate? That is, I can't use the same type in
> calling my_malloc(). So how can I pass a type to a function?
Maybe something like this?
#define TALLOC(x) {int p ; ((p = malloc(sizeof(x)) == NULL) ? \
{perror("Malloc") ; exit(errno) } : \
p ; }
The sizeof() will resolve the type into the required number of bytes,
such that
bptr = TALLOC(struct bogus) ;
will allocate the correct size buffer, while performing the check
(I hope, I haven't tested that macro...)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
David L. Cathey |INET: davidc@montagar.com
Montagar Software Concepts |UUCP: ...!montagar!davidc
P. O. Box 260772, Plano TX 75026-0772 |Fone: (214)-618-2117
Technical Details
Message-ID:
<01GPZBWYAOJ40001ZZ@esevvx.cica.es>Path:
arc1-ca.pugleaf.net!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!macro32Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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 From: REGI's <NUNEZ@esevvx.cica.es> Newsgroups: vmsnet.internals Subject: (None) Message-ID: <01GPZBWYAOJ40001ZZ@esevvx.cica.es> Date: Thu, 15 Oct 1992 14:37:00 UTC+0100 Organization: Macro32<==>Vmsnet.Internals Gateway X-Gateway-Source-Info: Mailing List Lines: 70