File bugzilla-348100-empty-radicals-window.patch of Package gjiten
--- gjiten-2.6/src/kanjidic.c 2006/10/29 18:52:29 1.19
+++ gjiten-2.6/src/kanjidic.c 2007/10/23 21:03:36 1.20
@@ -55,6 +55,7 @@
gchar kanjiselected[2];
gchar *radkfile = NULL;
guint32 radkfile_size;
+int radkfile_fd = -1;
extern guint32 srchpos;
GList *klinklist = NULL, *tmpklinklist = NULL;
@@ -775,7 +776,6 @@
gchar *radkfile_name = RADKFILE_NAME;
gchar *radkfile_ptr;
gchar *radkfile_end;
- int fd = 0;
RadInfo *rad_info = NULL;
KanjiInfo *kanji_info;
gunichar kanji;
@@ -789,13 +789,17 @@
error = TRUE;
}
radkfile_size = radk_stat.st_size;
- fd = open(radkfile_name, O_RDONLY);
- if (fd == -1) {
+ radkfile_fd = open(radkfile_name, O_RDONLY);
+ if (radkfile_fd == -1) {
g_error("**ERROR** radkfile: open()\n");
error = TRUE;
}
- radkfile = (gchar *) mmap(NULL, radkfile_size, PROT_READ, MAP_SHARED, fd, 0);
+ radkfile = (gchar *) mmap(NULL, radkfile_size, PROT_READ, MAP_SHARED, radkfile_fd, 0);
if (radkfile == NULL) gjiten_abort_with_msg("mmap() failed for radkfile\n");
+ if ( radkfile_fd != -1 ) {
+ close(radkfile_fd);
+ }
+ radkfile_fd = -1;
if (error == TRUE) {
gjiten_print_error(_("Error opening %s.\n "\
@@ -945,6 +949,13 @@
if (kanjiDic != NULL) {
KanjiDic *tmp;
radical_window_close();
+ if (radkfile != NULL) {
+ munmap(radkfile, radkfile_size);
+ radkfile = NULL;
+ if ( radkfile_fd != -1 ) {
+ close(radkfile_fd);
+ }
+ }
/* Avoid recursion */
tmp = kanjiDic;