On Wed, 2007-04-18 at 08:08 -0700, Alan Coopersmith wrote:
> Irene (Shi Ying) Huang wrote:
> > + aspell = fopen (dic, "r");
> > + perspell = fopen (filename, "a");
> > + if (g_file_test (filename, G_FILE_TEST_EXISTS))
> > + perspell = fopen (filename, "a");
> > + else {
> > + directory = g_build_filename (home_dir,
> ENCHANT_USER_PATH_EXTENSION, NULL);
> > + if (!g_file_test (directory, G_FILE_TEST_EXISTS) ||
> !g_file_test
> (directory, G_FILE_TEST_IS_DIR))
> > + g_mkdir (directory , 0700);
> > + perspell = fopen (filename, "w");
> > + }
>
> Looks like a memory/file descriptor leak, since the fopen() from the
> second line is just lost when you redo it in the if/else clauses.
Sorry that was a mistake
>
> Also, since you only close aspell & perspell if both are opened, do
> you leak in cases where one fails but the other succeeded?
>
> > + if (fgets (line, sizeof (line), aspell)) {
> > + while (fgets (line, sizeof (line), aspell))
> > + fputs (line, perspell);
>
> Are you intentionally throwing away the first line from the aspell
> file? If not, why not just dump the if line altogether? If so,
> it would be good to include a comment as to why, so future programmers
> looking at it don't wonder why.
yes I intentionally throw the first line away, because of different
dictionary format between aspell and hunspell. :)
The new patch is attached :) please review
--irene
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: enchant-03-personaldic.diff
Type: text/x-patch
Size: 2625 bytes
Desc: not available
URL:
<http://mail.opensolaris.org/pipermail/jds-review/attachments/20070420/82ec37ec/attachment.bin>