josh at metropark.com
Wed Aug 17 21:50:54 GMT 2005
Pointer coercion is standard terminology, it is used when you force cast a
pointer as a different data type.
Btw, most processors since the late 90's can handle a variable not aligned
to their word length, so it would be uncommon.
Good question, Sergey.
> -----Original Message-----
> From: owner-freebsd-questions at freebsd.org [mailto:owner-freebsd-
> questions at freebsd.org] On Behalf Of Erik Trulsson
> Sent: Wednesday, August 17, 2005 4:33 PM
> To: Sergey Matveychuk
> Cc: questions at freebsd.org
> Subject: Re: man malloc
> On Thu, Aug 18, 2005 at 01:03:46AM +0400, Sergey Matveychuk wrote:
> > I know it may be stupid, but I can't understand this sentence from
> > malloc(3) man page:
> > "
> > The allocated space is suitably aligned (after possible pointer
> > coercion) for storage of any type of object.
> > "
> > What does "suitable aligned for storage of *any* type of object" means?
> In what way is that difficult to understand? It can't really be expressed
> simpler, and it means exactly what it says: That the storage allocated by
> suitably aligned for storing any kind of object.
> As an example, it is not uncommon for many systems to require that a
> 32-bit integer must be aligned on a 4-byte boundary. (I.e. if the CPU
> to access such an object placed on an address that is not a multiple of 4,
> then the program will crash.) Exactly what alignment is required for
> different objects can vary quite a bit, but malloc guarantees that the
> storage it allocates is aligned in such a way that you can store any kind
> object in it (assuming it is large enough, of course.)
> > What is pointer coercion?
> No idea. It is not standard terminology anway.
> > I have no pointer before malloc() returns.
> Then where do you store the value returned by malloc?
> You almost certainly do have some pointer even before malloc returns, but
> that pointer might not contain any useful value.
> <Insert your favourite quote here.>
> Erik Trulsson
> ertr1013 at student.uu.se
> freebsd-questions at freebsd.org mailing list
> To unsubscribe, send any mail to
"freebsd-questions-unsubscribe at freebsd.org"
More information about the freebsd-questions