From 57f86fb3a8bde60e8c99a46fdccd0dc12377ffd2 Mon Sep 17 00:00:00 2001 From: Edmondo Tommasina Date: Wed, 21 Dec 2016 22:58:11 +0100 Subject: [PATCH] gallium/hud: move file initialization to a function MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The function will be used later to create the filedescriptor for other metrics. Signed-off-by: Marek Olšák --- src/gallium/auxiliary/hud/hud_context.c | 17 +++++++++++++++++ src/gallium/auxiliary/hud/hud_driver_query.c | 12 +----------- src/gallium/auxiliary/hud/hud_private.h | 2 ++ 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c index edd831a7f7b..779c11693c8 100644 --- a/src/gallium/auxiliary/hud/hud_context.c +++ b/src/gallium/auxiliary/hud/hud_context.c @@ -865,6 +865,23 @@ hud_graph_destroy(struct hud_graph *graph) FREE(graph); } +void +hud_graph_set_dump_file(struct hud_graph *gr) +{ + const char *hud_dump_dir = getenv("GALLIUM_HUD_DUMP_DIR"); + char *dump_file; + + if (hud_dump_dir && access(hud_dump_dir, W_OK) == 0) { + dump_file = malloc(strlen(hud_dump_dir) + sizeof(gr->name)); + if (dump_file) { + strcpy(dump_file, hud_dump_dir); + strcat(dump_file, gr->name); + gr->fd = fopen(dump_file, "w+"); + free(dump_file); + } + } +} + /** * Read a string from the environment variable. * The separators "+", ",", ":", and ";" terminate the string. diff --git a/src/gallium/auxiliary/hud/hud_driver_query.c b/src/gallium/auxiliary/hud/hud_driver_query.c index 23fda0187dd..d80b8eda60c 100644 --- a/src/gallium/auxiliary/hud/hud_driver_query.c +++ b/src/gallium/auxiliary/hud/hud_driver_query.c @@ -351,8 +351,6 @@ hud_pipe_query_install(struct hud_batch_query_context **pbq, { struct hud_graph *gr; struct query_info *info; - const char *hud_dump_dir = getenv("GALLIUM_HUD_DUMP_DIR"); - char *dump_file; gr = CALLOC_STRUCT(hud_graph); if (!gr) @@ -380,15 +378,7 @@ hud_pipe_query_install(struct hud_batch_query_context **pbq, info->result_index = result_index; } - if (hud_dump_dir && access(hud_dump_dir, W_OK) == 0) { - dump_file = malloc(strlen(hud_dump_dir) + sizeof(gr->name)); - if (dump_file) { - strcpy(dump_file, hud_dump_dir); - strcat(dump_file, gr->name); - gr->fd = fopen(dump_file, "w+"); - free(dump_file); - } - } + hud_graph_set_dump_file(gr); hud_pane_add_graph(pane, gr); pane->type = type; /* must be set before updating the max_value */ diff --git a/src/gallium/auxiliary/hud/hud_private.h b/src/gallium/auxiliary/hud/hud_private.h index fa1cd8b9a45..5132b3d2c4f 100644 --- a/src/gallium/auxiliary/hud/hud_private.h +++ b/src/gallium/auxiliary/hud/hud_private.h @@ -104,6 +104,8 @@ boolean hud_driver_query_install(struct hud_batch_query_context **pbq, void hud_batch_query_update(struct hud_batch_query_context *bq); void hud_batch_query_cleanup(struct hud_batch_query_context **pbq); +void hud_graph_set_dump_file(struct hud_graph *gr); + #if HAVE_GALLIUM_EXTRA_HUD int hud_get_num_nics(bool displayhelp); #define NIC_DIRECTION_RX 1 -- 2.30.2