[packagekit] pk-glib2 problem

Richard Hughes hughsient at gmail.com
Wed Sep 16 10:48:12 PDT 2009


2009/9/16 Daniel Nicoletti <dantti85-pk at yahoo.com.br>:
> Will this will leak right?
> FindPkg( pk_package_id_split(pi)[PK_PACKAGE_ID_NAME] );

Yes.

> instead i should:
> gchar **parts;
> parts = pk_package_id_split (package->priv->id);
> FindPkg( parts[PK_PACKAGE_ID_NAME] );
> g_strfreev (parts);
>
> right?

Correct.

> can't we have a more  convenient function to get name, version instead?

Well, you could write _get_name(), get_version() etc methods, but
it'll split the string on each request and be very inefficent. The new
way is quite a bit faster (less copies and pointer lookups) and easier
to debug.

> using p->name imo was much easier...

Sure, but you have to ask yourself, why are you using the package
_name_ so much -- shouldn't you be using the package_id internaly
more?

Richard.



More information about the PackageKit mailing list