Re: memcpy

2007-06-21 Thread Andy Lester
On Jun 21, 2007, at 1:39 AM, Allison Randal wrote: Andy Lester wrote: I guess I don't see the need to document a standard C behavior with a macro. If you had read all the way through the message, you would see that the biggest benefit is the ability to hang debugging hooks off the macro

Re: memcpy

2007-06-20 Thread Allison Randal
Andy Lester wrote: I guess I don't see the need to document a standard C behavior with a macro. If you had read all the way through the message, you would see that the biggest benefit is the ability to hang debugging hooks off the macro. We have a number of these kinds of debugging hooks t

Re: memcpy

2007-06-20 Thread Andy Lester
On Jun 20, 2007, at 1:05 PM, Mark J. Reed wrote: Incrementing a var is much less likely to have unpredictable effects due to modifying the wrong memory. Sure, x might be a pointer, and things might gang agley there, but pointers getting set to the wrong type of pointee is a pretty common probl

Re: memcpy

2007-06-20 Thread Mark J. Reed
On 6/20/07, Andy Lester <[EMAIL PROTECTED]> wrote: My point is that *d = *s; is no more a weird cryptic construct than n++; or while (*s) *d++ = *s++; for that matter. That's a very good point. As you said in the original message, all you need is *dest = *src; since the c

Re: memcpy

2007-06-20 Thread Mark J. Reed
On 6/20/07, Andy Lester <[EMAIL PROTECTED]> wrote: I guess I don't see the need to document a standard C behavior with a macro. We don't have #define inc(x) (x)++ do we? Incrementing a var is much less likely to have unpredictable effects due to modifying the wrong memory. Sure, x might

Re: memcpy

2007-06-20 Thread Andy Lester
On Jun 20, 2007, at 11:50 AM, Allison Randal wrote: I wasn't entirely happy with either option, so I asked around a bit for other ideas. I like the macro approach below, it gives us both self documentation and better checking for the size of the two structs. I guess I don't see the need

Re: memcpy

2007-06-20 Thread Allison Randal
I wasn't entirely happy with either option, so I asked around a bit for other ideas. I like the macro approach below, it gives us both self documentation and better checking for the size of the two structs. Allison Original Message From: Nick Forrette <[EMAIL PROTECTED]> To:

Re: memcpy

2007-06-19 Thread Leopold Toetsch
Am Montag, 18. Juni 2007 23:48 schrieb Andy Lester: > Is there a reason we use > >    memcpy( dest, src, sizeof(FOO) ); > > instead of > >    *dest = *src; > > The latter should be the exact same code, but be much less likely to   > be screwed up. I'm using a lot of the first kind. The main reason

Re: memcpy

2007-06-19 Thread Andy Armstrong
On 19 Jun 2007, at 08:48, Joshua Isom wrote: On Jun 18, 2007, at 4:48 PM, Andy Lester wrote: Is there a reason we use memcpy( dest, src, sizeof(FOO) ); instead of *dest = *src; The latter should be the exact same code, but be much less likely to be screwed up. No, they're extremely

Re: memcpy

2007-06-19 Thread Joshua Isom
On Jun 18, 2007, at 4:48 PM, Andy Lester wrote: Is there a reason we use memcpy( dest, src, sizeof(FOO) ); instead of *dest = *src; The latter should be the exact same code, but be much less likely to be screwed up. No, they're extremely different. In the first, the data of FOO is