Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Question about malloc, alignment, ...
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="The Real OS/2 Guy, post: 1674144"] And for that he has to know how pointer arithmetic works. For that it is guaranteed that any struct of a given struct type has equal size. Sou you can easy build single structs and struct arrays dynamically and not only statically. It is guaranteed that each pointer to each struct has the same size and aligned well. sizeof(struct) gives you always the size of a struct. Adding this to a pinter to char gives you always an well aligned address to start a new struct - but native pointer arithmetic on the right type does it as well. I'd made the test not too long ago by writing an ANSI C program based on that principe to get it in production on 5 different compilers in 5 different architectures - 16 and 32 bit, some of them were sensitive against misalignment. Written and debuged on ONE mashine (really insensitve against misalignment), compiled and linked on all. Whereas I'd seen the comilers of the four other mashines the first time as I had to start to compile the program on that mashines. My knowledge of that mashines was 0, zero, void at that time. As the program was tested well as I started to port it nothing was to change. The program was written completely without #ifdef, pure ANSI C. Massive pointer arithmetic was needed to get all requiremts done - the same as I'd desribed in the artikles before. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Question about malloc, alignment, ...
Top