man malloc

Dmitry Mityugov dmitry.mityugov at gmail.com
Thu Aug 18 18:17:59 GMT 2005


On 8/18/05, Giorgos Keramidas <keramida at ceid.upatras.gr> wrote:
> On 2005-08-18 12:08, Sergey Matveychuk <sem at freebsd.org> wrote:
> >Chuck Swiger wrote:
> >>>What is pointer coercion? I have no pointer before malloc() returns.
> >>
> >> Right.  Well, malloc returns a (void *), but most people want to use the
> >> memory malloc returns to hold their own arrays, structs, whatever, which
> >> means that you need to be able to coerce the (void *) malloc gave you
> >> into whatever pointer type you want to actually use.
> >>
> >> So the memory malloc gives you needs to be aligned so that it's OK to be
> >> used for even the most restrictive datatype known to the system,
> >> commonly 8, 16, or 32 bytes.
> >
> > Pointer coercion means a type cast? I see now.
> > I read it as 'force change of pointer value' before.
> 
> It may be surprising, but casting back and forth *MAY* change the value
> of the pointer.
...

Could you back up this assertion with an example, please?


-- 
Dmitry Mityugov, St. Petersburg, Russia
I ignore all messages with confidentiality statements

"We live less by imagination than despite it" - Rockwell Kent, "N by E"


More information about the freebsd-questions mailing list