Subject: Re: Making a common API for cpu frequency drivers
To: Jason Thorpe <thorpej@shagadelic.org>
From: Daniel Carosone <dan@geek.com.au>
List: tech-kern
Date: 09/02/2006 07:57:27
--7VkxxUl3xUvPtoxk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Sep 01, 2006 at 02:48:25PM -0700, Jason Thorpe wrote:
>  --- snip ---
>=20
> You don't have to specify the capacity -- the array with automatically =
=20
> expand as necessary.  That said, if you know that it will contain =20
> exactly two entries and no more, then create with that capacity.  But =20
> your example creates an array with a larger capacity than entries that =
=20
> you add.
>=20
>  --- snip ---
>=20
> You need to prop_object_release() the array
>=20
> Reasons:
> 1- On failure, you need to free the array.
>=20
> 2- On success, the dictionary has retained it (bumped the ref count), =20
> and you need to release your reference now that you're done with the =20
> array, else you'll leak the reference and thus the memory.
>=20
>  --- snip ---
>=20
> And finally, construct the array BEFORE storing it in the dictionary.  =
=20
> That way the "I am done with the array" is more clear, and you also =20
> avoid having partially constructed data visible in the dictionary.

These are great usage tips and conventions, can they be noted
somewhere appropriate in the documentation, to establish the pattern
early and help avoid introducing such problems with new proplib uses?

--
Dan.

--7VkxxUl3xUvPtoxk
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (NetBSD)

iD8DBQFE+KzHEAVxvV4N66cRAmXxAJ4oXUsbe1yCtQnzyvZpkpqZ8eIWNACglSV8
Qi8gwapUNTalcyLr6rZAqrA=
=Qv+i
-----END PGP SIGNATURE-----

--7VkxxUl3xUvPtoxk--