Skip to Content.
Sympa Menu

freetds - Re: [freetds] portable constructions

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frediano Ziglio <freddyz77 AT tin.it>
  • To: FreeTDS <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] portable constructions
  • Date: 02 Jan 2003 18:57:30 +0100

Il mer, 2003-01-01 alle 01:34, Brian Bruns ha scritto:
> 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.
> >

Buffer should always aligned. When read from wire to buffer we use code that
do not have alignment problem (from read.c) and save results in aligned
buffer.
When client try to copy have to pass variable so client buffer must be
aligned.
However it's not time to change all this behaviour... IMHO a TODO for next
release would be the best thing...

freddy77






Archive powered by MHonArc 2.6.24.

Top of Page