Subject: Re: unaligned access: how to track ?
To: Manuel Bouyer <>
From: Chris G. Demetriou <>
List: port-alpha
Date: 06/07/2000 10:07:12
Manuel Bouyer <> writes:
> Hum ok, so we should pad the key to the alignement required by the
> architecture.


As far as the 'db' API is concerned, it can return keys/data at random
offsets, completely disregarding the alignment of anything you supply.

No amount of padding you do on the input side will help that (because
who knows what it's packing them _against_, for all you know it's got
some internal structures that it uses which really are byte
strings... at least, it's allowed to).

The only solution is to copy the data after lookup, before accessing
them, if they're not aligned.  You can use ALIGN to help you check
this (but that's not portable code, if you care), or you can do the
conservative thing and always copy.

Chris Demetriou - -
Disclaimer: Not speaking for NetBSD, just expressing my own opinion.