[packagekit] [PATCH]Service Packs: Creation and Installation

Richard Hughes hughsient at gmail.com
Mon Aug 4 02:00:17 PDT 2008

On Sun, 2008-08-03 at 02:32 +0530, Shishir Goyal wrote:
> > Excellent, applied. Also, you should probably aim to fix all the FIXME's
> > in pk-generate-pack.c -- especially the one where you're using scandir.
> Tried fixing the FIXMEs in pkgenpack.
> Checked if the file already exists, and asked user input in main()
> itself, so as to avoid pkgenpack download the packages, in case user
> enters a 'no'.
> Patch Attached.Reviews.

I've applied this with a couple of little tweaks, thanks. I've also
noticed a couple of small memory leaks in your program. A memory leak
happens when you allocate some memory, but do not free it (usually using

You can test your program doing:

yum install valgrind (as root)
cd client
valgrind --leak-check=full ./.libs/lt-pkgenpack --verbose hal-info.pack hal-info

This will give you output at the end like this:

==25990== 10 bytes in 1 blocks are definitely lost in loss record 1 of 12
==25990==    at 0x4006AEE: malloc (vg_replace_malloc.c:207)
==25990==    by 0x8484F3: g_malloc (gmem.c:131)
==25990==    by 0x86291B: g_strconcat (gstrfuncs.c:259)
==25990==    by 0x80497A3: main (pk-generate-pack.c:477)
==25990== 64 bytes in 1 blocks are definitely lost in loss record 2 of 12
==25990==    at 0x4006C0C: realloc (vg_replace_malloc.c:429)
==25990==    by 0x8483D9: g_realloc (gmem.c:170)
==25990==    by 0x86335E: g_string_maybe_expand (gstring.c:359)
==25990==    by 0x863F48: g_string_insert_len (gstring.c:694)
==25990==    by 0x8642FF: g_string_append_len (gstring.c:842)
==25990==    by 0x83058B: g_build_path_va (gfileutils.c:1524)
==25990==    by 0x8306D3: g_build_filename (gfileutils.c:1794)
==25990==    by 0x8049FF1: main (pk-generate-pack.c:263)

You don't need to worry about the "possibly lost" output below these two.

In this case you are leaking 74 bytes of memory. In the first you're
using g_strconcat() in main() without freeing the result, and in the
second you are using g_build_filename() in pk_generate_pack_scan_dir().
Could you fix up these leaks and submit a patch please? Thanks.


More information about the PackageKit mailing list