Skip to Content.
Sympa Menu

freetds - Re: [freetds] portable constructions

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Brian Bruns <camber AT ais.org>
  • To: TDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] portable constructions
  • Date: Tue, 31 Dec 2002 19:34:24 -0500 (EST)

until you get bus errors on sparc and hp/ux for unaligned access. If
your going to change it back to a cast you need to make sure buffer is
aligned which may not be possible (comes unaligned in buffer from server).
We used to cast and moved to memcpy for that reason.

On Tue, 31 Dec 2002, 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.
>
> --jkl
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
>





Archive powered by MHonArc 2.6.24.

Top of Page