Groups | Search | Server Info | Login | Register


Groups > comp.lang.c.moderated > #503

Alignment calculation or something like that

From vijk <vijayx@gmail.com>
Newsgroups comp.lang.c.moderated
Subject Alignment calculation or something like that
Date 2011-02-01 16:29 -0600
Organization http://groups.google.com
Message-ID <clcm-20110201-0008@plethora.net> (permalink)

Show all headers | View raw


/** alignment is a power of 2, it is passed in as a hard coded int **/

1. void*p1,**p2

2. int offset = alignment - 1 + sizeof(void*);

3. p2 = (void**)(((size_t)(p1) + offset) & ~(alignment - 1));

4. p2[-1] = p1;


I am trying to understand what/how lines 2 and 3 are doing/calculated.
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.

Back to comp.lang.c.moderated | Previous | NextNext in thread | Find similar


Thread

Alignment calculation or something like that vijk <vijayx@gmail.com> - 2011-02-01 16:29 -0600
  Re: Alignment calculation or something like that Andreas <a.k.k@nospam.org> - 2011-02-04 12:46 -0600

csiph-web