freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: Michael Peppler <mpeppler AT peppler.org>
- To: freetds AT lists.ibiblio.org
- Subject: Re: [freetds] portable constructions
- Date: 31 Dec 2002 14:53:04 -0800
On Tue, 2002-12-31 at 14:34, James K. Lowden wrote:
> I often see code like this:
>
> CS_VOID * buffer;
> CS_INT int_val;
> memcpy(buffer, &int_val, sizeof(CS_INT));
>
> I wouldn't use memcpy(). I would cast it:
>
> *(CS_INT*) buffer = int_val;
>
> Is there some reason not to do that? Surely my code is easier to
> understand and requires fewer instructions.
I've used both. I think the latter is potentially open to memory
alignment problems (and a good C compiler might actually optimize away
the call to memcpy()).
Michael
--
Michael Peppler Data Migrations, Inc.
mpeppler AT peppler.org http://www.mbay.net/~mpeppler
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or
long term contract positions - http://www.mbay.net/~mpeppler/resume.html
Attachment:
signature.asc
Description: This is a digitally signed message part
-
[freetds] portable constructions,
James K. Lowden, 12/31/2002
- Re: [freetds] portable constructions, Michael Peppler, 12/31/2002
- Re: [freetds] portable constructions, Brian Bruns, 12/31/2002
Archive powered by MHonArc 2.6.24.