projects
/
babeltrace.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix babeltrace-log incorrect timestamp type
[babeltrace.git]
/
formats
/
registry.c
diff --git
a/formats/registry.c
b/formats/registry.c
index 17bc3bce7d36a3d68a9975ee5ac4b7d5c006b0e5..656d6360aca0030856c3a08830998cea1ea4119f 100644
(file)
--- a/
formats/registry.c
+++ b/
formats/registry.c
@@
-21,6
+21,11
@@
#include <errno.h>
#include <stdio.h>
#include <errno.h>
#include <stdio.h>
+struct walk_data {
+ FILE *fp;
+ int iter;
+};
+
static int init_done;
void __attribute__((constructor)) format_init(void);
void __attribute__((destructor)) format_finalize(void);
static int init_done;
void __attribute__((constructor)) format_init(void);
void __attribute__((destructor)) format_finalize(void);
@@
-42,19
+47,27
@@
struct format *bt_lookup_format(GQuark qname)
static void show_format(gpointer key, gpointer value, gpointer user_data)
{
static void show_format(gpointer key, gpointer value, gpointer user_data)
{
-
FILE *fp
= user_data;
+
struct walk_data *data
= user_data;
- fprintf(
fp, "format: %s\n
",
+ fprintf(
data->fp, "%s%s", data->iter ? ", " : "
",
g_quark_to_string((GQuark) (unsigned long) key));
g_quark_to_string((GQuark) (unsigned long) key));
+ data->iter++;
}
void bt_fprintf_format_list(FILE *fp)
{
}
void bt_fprintf_format_list(FILE *fp)
{
- fprintf(fp, "Formats available:\n");
+ struct walk_data data;
+
+ data.fp = fp;
+ data.iter = 0;
+
+ fprintf(fp, "Formats available: ");
if (!init_done)
return;
if (!init_done)
return;
- g_hash_table_foreach(format_registry, show_format, fp);
- fprintf(fp, "End of formats available.\n");
+ g_hash_table_foreach(format_registry, show_format, &data);
+ if (data.iter == 0)
+ fprintf(fp, "<none>");
+ fprintf(fp, ".\n");
}
int bt_register_format(struct format *format)
}
int bt_register_format(struct format *format)
@@
-73,6
+86,8
@@
int bt_register_format(struct format *format)
void format_init(void)
{
void format_init(void)
{
+ if (init_done)
+ return;
format_registry = g_hash_table_new(g_direct_hash, g_direct_equal);
assert(format_registry);
init_done = 1;
format_registry = g_hash_table_new(g_direct_hash, g_direct_equal);
assert(format_registry);
init_done = 1;
This page took
0.022941 seconds
and
4
git commands to generate.