Article View: comp.lang.c.moderated
Article #2540Re: void* type
From: Lawrence Kirby
Date: Sat, 06 Apr 1996 15:06
Date: Sat, 06 Apr 1996 15:06
22 lines
1576 bytes
1576 bytes
In article <4k1q3p$5bj@solutions.solon.com> news@Thinkage.On.CA writes: >malloc returns a void *. The assignments to d and p convert the void * to >double * and char *, respectively. No change is needed for the char *, but >the return value from malloc is reduced from 32 bits to 16 bits to convert >to a double *. Since malloc guarantees alignment (actually, only *after* >casting, but only a very malicious malloc would do that to you), this can >safely be done. The standard actually says 7.10.3: "The pointer returned if the allocation succeeds is suitably aligned so that it may be assigned to a pointer to any type of object..." So the alignment is guaranteed for the pointer returned i.e. prior to conversion. -- ----------------------------------------- Lawrence Kirby | fred@genesis.demon.co.uk Wilts, England | 70734.126@compuserve.com -----------------------------------------
Technical Details
Message-ID:
<4k619q$aq4@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailReferences:
<4jmcnh$lqk@solutions.solon.com> <4jq24r$aah@solutions.solon.com> <4jv7ge$d49@solutions.solon.com> <4k1q3p$5bj@solutions.solon.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: Lawrence Kirby <fred@genesis.demon.co.uk> Newsgroups: comp.lang.c.moderated Subject: Re: void* type Date: 6 Apr 1996 09:06:34 -0600 Organization: none Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4k619q$aq4@solutions.solon.com> References: <4jmcnh$lqk@solutions.solon.com> <4jq24r$aah@solutions.solon.com> <4jv7ge$d49@solutions.solon.com> <4k1q3p$5bj@solutions.solon.com> Reply-To: fred@genesis.demon.co.uk NNTP-Posting-Host: solutions.solon.com X-NNTP-Posting-Host: genesis.demon.co.uk X-Newsreader: Demon Internet Simple News v1.27 X-Mail2News-Path: genesis.demon.co.uk