On 2/10/06, The Fool <[EMAIL PROTECTED]> wrote:

>
> From: Bryon Daly <[EMAIL PROTECTED]>
>
> On 2/9/06, The Fool <[EMAIL PROTECTED]> wrote:
> >Ok so this is what I've been doing:
>
> I'll cut down to the meat of it:
>
> >   *((int *) &Mem[PutAt * __Int_Size__])       = PutMe;
>
> This looks reasonable.  I presume that Mem[] is a char or byte array of
> some
> kind...  Are you only writing ints into Mem[]?  If you're going to mix
> data
> types in the same buffer, you'll need to consider data packing or padding,
> and possibly be aware of data alignment issues.
>
> -------
>
> The Data I'm Copying from isn't exactly contigous:


I meant where you are writing the data to, not from.  It looks from your
code that you could potentially do something like:
PutInt64(1,32);
PutInt(2,567);  // This int overwrites the upper 4 bytes of the int64 you
just wrote
or
PutChar(1, 32);
PutInt(2,567);   // Maybe you don't care, but this leaves a 3-byte gap
between the 1st char and the int

I also mentioned  you should be aware of data alignment: IIRC, bad data
alignment only causes a performance hit on Intel, but you'll get a bus error
on most other platforms.  Your code looks like it will keep things aligned,
though, so you should be OK there.

Alberto also had a good point about the CurrentSize check.  Also note that
for PutAt==0, any CurrentSize value >= 0 will get through the check.
_______________________________________________
http://www.mccmedia.com/mailman/listinfo/brin-l

Reply via email to