diff options
| author | TazyFoundSoup <gardendistrict0x0@outlook.com> | 2026-03-30 16:22:40 +1100 |
|---|---|---|
| committer | TazyFoundSoup <gardendistrict0x0@outlook.com> | 2026-03-30 16:22:40 +1100 |
| commit | 92bea06509b97d951ba9a8c7a9eee9dfcc79e2d6 (patch) | |
| tree | 8ef1353b19539befa5526186222217fb46ec8cdf /src | |
| parent | 656bdd0e73f1dde3b5b22140e0f27f9bd8951c29 (diff) | |
refactor(dbg): Use context instead of debugging global states
Diffstat (limited to 'src')
| -rw-r--r-- | src/dbg.c | 26 |
1 files changed, 10 insertions, 16 deletions
@@ -1,29 +1,23 @@ #include <tinyff/dbg.h> -FILE *intff_debug_stream = NULL; -ff_flag intff_debug_enabled = 0; - -ff_result ff_set_debug_stream(FILE *stream) +ff_result ff_set_debug_stream(ff_stream* stream, ff_ctx* ctx) { - intff_debug_stream = stream; - intff_debug_enabled = (stream != NULL); + ctx->ff_debug_stream = stream; + ctx->ff_debug_enabled = (stream != NULL); - ff_dprintf("tinyff 0.1.0 debug stream\n"); - ff_dprintf("For more information, visit\n"); - ff_dprintf("https://github.com/TazyFoundSoup/tinyff\n"); - ff_dprintf("------------------------------\n"); + ff_dprintf(ctx, "tinyff 0.1.0 debug stream\n"); + ff_dprintf(ctx, "For more information, visit\n"); + ff_dprintf(ctx, "https://github.com/TazyFoundSoup/tinyff\n"); + ff_dprintf(ctx, "------------------------------\n"); return FF_RESULT_OK; } -ff_result ff_dprintf(const char *format, ...) +ff_result ff_dprintf(ff_ctx* ctx, const char *msg) { - if (!intff_debug_enabled || !intff_debug_stream) return FF_RESULT_WARN_DEBUG_DISABLED; + if (!ctx->ff_debug_enabled || !ctx->ff_debug_stream) return FF_RESULT_WARN_DEBUG_DISABLED; - va_list args; - va_start(args, format); - vfprintf(intff_debug_stream, format, args); - va_end(args); + ctx->ff_debug_stream->write(msg, ff_strlen(msg), ctx->ff_debug_stream->user); return FF_RESULT_OK; } |
