Skip to content

Commit

Permalink
Call j_init and j_fini automatically
Browse files Browse the repository at this point in the history
Keep them public for now. Repeated invocations will simply return
immediately.
  • Loading branch information
michaelkuhn committed Dec 12, 2018
1 parent a9916cb commit 7582937
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 24 deletions.
4 changes: 0 additions & 4 deletions benchmark/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ main (int argc, char** argv)
opt_machine_separator = g_strdup("\t");
}

j_init();

j_benchmark_semantics = j_semantics_new_from_string(opt_template, opt_semantics);
j_benchmark_timer = g_timer_new();

Expand Down Expand Up @@ -214,8 +212,6 @@ main (int argc, char** argv)
g_timer_destroy(j_benchmark_timer);
j_semantics_unref(j_benchmark_semantics);

j_fini();

g_free(opt_machine_separator);
g_free(opt_path);
g_free(opt_semantics);
Expand Down
4 changes: 0 additions & 4 deletions cli/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ main (int argc, char** argv)

command = argv[1];

j_init();

arguments = g_new(gchar const*, argc - 1);

for (i = 2; i < argc; i++)
Expand Down Expand Up @@ -139,7 +137,5 @@ main (int argc, char** argv)
j_cmd_usage();
}

j_fini();

return (success) ? 0 : 1;
}
4 changes: 0 additions & 4 deletions fuse/julea-fuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ main (int argc, char** argv)
{
gint ret;

j_init();

ret = fuse_main(argc, argv, &jfs_vtable, NULL);

j_fini();

return ret;
}
5 changes: 3 additions & 2 deletions include/jcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ G_END_DECLS

G_BEGIN_DECLS

void j_init (void);
void j_fini (void);
// FIXME copy and use GLib's G_DEFINE_CONSTRUCTOR/DESTRUCTOR
void __attribute__((constructor)) j_init (void);
void __attribute__((destructor)) j_fini (void);

JConfiguration* j_configuration (void);

Expand Down
10 changes: 8 additions & 2 deletions lib/jcommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ j_init (void)
gchar const* kv_component;
gchar const* kv_path;

g_return_if_fail(!j_is_initialized());
if (j_is_initialized())
{
return;
}

common = g_slice_new(JCommon);
common->configuration = NULL;
Expand Down Expand Up @@ -218,7 +221,10 @@ j_fini (void)
{
JCommon* common;

g_return_if_fail(j_is_initialized());
if (!j_is_initialized())
{
return;
}

j_trace_enter(G_STRFUNC, NULL);

Expand Down
4 changes: 0 additions & 4 deletions test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ main (int argc, char** argv)

g_test_init(&argc, &argv, NULL);

j_init();

// Core
test_background_operation();
test_batch();
Expand All @@ -53,7 +51,5 @@ main (int argc, char** argv)

ret = g_test_run();

j_fini();

return ret;
}
4 changes: 0 additions & 4 deletions tools/statistics.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ main (int argc, char** argv)
(void)argc;
(void)argv;

j_init();

get_all = 1;
configuration = j_configuration();
statistics_total = j_statistics_new(FALSE);
Expand Down Expand Up @@ -145,7 +143,5 @@ main (int argc, char** argv)

j_statistics_free(statistics_total);

j_fini();

return 0;
}

0 comments on commit 7582937

Please sign in to comment.