void help_free(help_t *h)
{
+#if GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 8
g_mapped_file_free(h->file);
+#else
+ g_free(h->file);
+#endif
g_hash_table_destroy(h->entries);
g_free(h);
}
h = g_new0 (help_t, 1);
+#if GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 8
h->file = g_mapped_file_new(helpfile, TRUE, &error);
if (h->file != NULL) {
len = g_mapped_file_get_length(h->file);
if( h->file == NULL ) {
log_global(LOG_WARNING, "Unable to open help file `%s': %s", helpfile,
error->message);
- g_free( h );
+ help_free( h );
return NULL;
}
+#else
+ if (!g_file_get_contents(helpfile, &h->file, &len, &error)) {
+ log_global(LOG_WARNING, "Unable to open help file `%s': %s", helpfile,
+ error->message);
+ help_free( h );
+ return NULL;
+
+ }
+#endif
h->entries = help_build_hash(data, len);
- if (h->entries == NULL) {
- g_mapped_file_free(h->file);
- g_free(h);
- }
+
return h;
}