Re: Dynamic buffer library
- From: Andrew Poelstra <apoelstra@xxxxxxxxxx>
- Date: Thu, 31 Aug 2006 15:29:19 GMT
Michael Mair <Michael.Mair@xxxxxxxxxxxxxxx> writes:
Andrew Poelstra schrieb:
"Spiros Bousbouras" <spibou@xxxxxxxxx> writes:
the "items" starting at buf[3]. Are the items of typeFrom the code it seems that your intention is to store
size_t ? If not how do you know that buf[3] is properly
aligned ?
The items may not be of size_t. I don't know that they're properly
aligned (this is an example of the UB I knew that I missed). What
would be the best way for me to guarantee alignment? Am I going to
need to use a union?
There is no portable way that does all the work; some time ago,
I wrote a "memsize" solution that does store the size in a standard
conforming albeit ugly and wasteful way. I asked for a code review
back then but did not receive any response; you are welcome to take
out the useful part of the ideas:
<3649apF4s752rU1@xxxxxxxxxxxxxx>
Download seems still possible.
Thanks! That'll be useful, and probably end up being my solution.
A quick question, though, is struct padding consistant?
That is, for every struct { int x, size_t y, float z }, will (&z - &x)
always be the same number? Because if so, a more efficient solution
could be found.
--
Andrew Poelstra <http://www.wpsoftware.net/projects>
To reach me by email, use `apoelstra' at the above domain.
"Do BOTH ends of the cable need to be plugged in?" -Anon.
.
- Follow-Ups:
- Re: Dynamic buffer library
- From: Michael Mair
- Re: Dynamic buffer library
- References:
- Dynamic buffer library
- From: Andrew Poelstra
- Re: Dynamic buffer library
- From: Spiros Bousbouras
- Re: Dynamic buffer library
- From: Andrew Poelstra
- Re: Dynamic buffer library
- From: Michael Mair
- Dynamic buffer library
- Prev by Date: Initializing constants
- Next by Date: Re: c code reusability
- Previous by thread: Re: Dynamic buffer library
- Next by thread: Re: Dynamic buffer library
- Index(es):
Relevant Pages
|