Subject: Re: CVS commit: src/include
To: Elad Efrat <elad@NetBSD.org>
From: Jason Thorpe <email@example.com>
Date: 02/18/2006 06:31:32
On Feb 18, 2006, at 4:29 AM, Elad Efrat wrote:
> would it be possible to avoid memory allocation and just typedef
> the struct? (say, pw_policy_t)
No, simply typedef'ing the struct still exposes the size and internal
layout to callers unless you do:
typedef struct pw_policy *pw_policy_t;
in the public header file and declare pw_policy ONLY in pw_policy.c.
In this case, you still need to use malloc to allocate the structure
on behalf of the caller.
I still prefer having the typedef, because I think that's a cleaner
way to pass around pointers to opaque data types.