[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <48FC9BB4.3050603@nortel.com>
Date: Mon, 20 Oct 2008 08:54:44 -0600
From: "Chris Friesen" <cfriesen@...tel.com>
To: Maxim Levitsky <maximlevitsky@...il.com>
CC: Chris Snook <csnook@...hat.com>, linux-kernel@...r.kernel.org
Subject: Re: [Slightly off topic] A question about R/B trees.
Maxim Levitsky wrote:
> Say you allocate a piece of memory using kmalloc, and write there, a
> structure that contains a r/b tree item. I agree that gcc will ensure
> that offset from start of that structure to first byte of the tree
> item will be aligned.
>
> But what if malloc returned a misaligned pointer? This will ensure
> that virtual address of the tree item won't be aligned. (I know it
> doesn't, but this isn't a assumption about gcc anymore)
malloc() can't return a misaligned pointer. From the spec: "The
pointer returned if the allocation succeeds shall be suitably aligned so
that it may be assigned to a pointer to any type of object..."
Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists