Re: How to get aligned memory?

Perry Harrington (pedward@sun4.apsoft.com)
Thu, 30 Jul 1998 19:01:34 -0700 (PDT)


I might add that Solaris defines memalign(3C) as a user interface.

It's essentially malloc with power of 2 alignments. You can't simulate
it in your program w/o retaining the original pointer malloc returned.

--Perry

> > This can be done in one line, with one pointer, but I will do it
> > step-by-step....
> >
> > funny struct *bits;
> > char *foo, *bar;
> > foo = (char *) malloc(WHATEVER); /* Waste 16 bits */
> > bar = foo;
> > foo += 0x00000010;
> > foo &= 0xfffffff0;
> > bits = (funny struct *) foo;
> > ........
> > do stuff
> > free(bar);

-- 
Perry Harrington       Linux rules all OSes.    APSoft      ()
email: perry@apsoft.com 			Think Blue. /\

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html