From owner-freebsd-questions@FreeBSD.ORG Wed Aug 17 21:50:54 2005 Return-Path: X-Original-To: questions@freebsd.org Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A2F6116A420; Wed, 17 Aug 2005 21:50:54 +0000 (GMT) (envelope-from josh@metropark.com) Received: from web.metropark.com (209.248.134.200.nw.nuvox.net [209.248.134.200]) by mx1.FreeBSD.org (Postfix) with ESMTP id F07D443D48; Wed, 17 Aug 2005 21:50:53 +0000 (GMT) (envelope-from josh@metropark.com) Received: (from root@localhost) by web.metropark.com (8.12.10/8.12.3) id j7HLpPEC028936; Wed, 17 Aug 2005 16:51:25 -0500 (CDT) (envelope-from josh@metropark.com) Received: from jweaver (users.metropark.com [209.248.134.245]) by web.metropark.com (8.12.10/8.12.3av) with ESMTP id j7HLpNTv028906; Wed, 17 Aug 2005 16:51:23 -0500 (CDT) (envelope-from josh@metropark.com) Message-Id: <200508172151.j7HLpNTv028906@web.metropark.com> From: "Joshua Weaver" To: "'Erik Trulsson'" , "'Sergey Matveychuk'" Date: Wed, 17 Aug 2005 16:51:29 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.6353 In-Reply-To: <20050817213243.GA26065@falcon.midgard.homeip.net> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 Thread-Index: AcWjc2H1Dnp5+HUhTBKd3LOG+HZe3AAAiGjA X-Virus-Scanned: by AMaViS perl-11 Cc: questions@freebsd.org Subject: RE: man malloc X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Aug 2005 21:50:54 -0000 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. Josh > -----Original Message----- > From: owner-freebsd-questions@freebsd.org [mailto:owner-freebsd- > questions@freebsd.org] On Behalf Of Erik Trulsson > Sent: Wednesday, August 17, 2005 4:33 PM > To: Sergey Matveychuk > Cc: questions@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 any > simpler, and it means exactly what it says: That the storage allocated by malloc is > 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 tries > 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. > > > -- > > Erik Trulsson > ertr1013@student.uu.se > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"