summaryrefslogtreecommitdiff
path: root/src/dbg.c
diff options
context:
space:
mode:
authorTazyFoundSoup <gardendistrict0x0@outlook.com>2026-04-14 11:08:56 +1000
committerTazyFoundSoup <gardendistrict0x0@outlook.com>2026-04-14 11:08:56 +1000
commit097ad322e0cbe5ca72a3d7c1938f2925547c196b (patch)
treeed76db5572e43f3aad26a1f2ce461cd4287bc1c0 /src/dbg.c
parentd44fb19da9f3d06f8873958e10647d5f0eae7789 (diff)
fix(dbg): ff_dprintf null write callback check
Diffstat (limited to 'src/dbg.c')
-rw-r--r--src/dbg.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/dbg.c b/src/dbg.c
index afd9008..ab93157 100644
--- a/src/dbg.c
+++ b/src/dbg.c
@@ -1,23 +1,20 @@
+#include <tinyff/stream.h>
#include <tinyff/dbg.h>
ff_result ff_set_debug_stream(ff_stream* stream, ff_ctx* ctx)
{
- ctx->ff_debug_stream = stream;
+ ctx->ff_debug_stream = *stream;
ctx->ff_debug_enabled = (stream != NULL);
- 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");
-
+ // TODO: Add banner back maybe
+
return FF_RESULT_OK;
}
ff_result ff_dprintf(ff_ctx* ctx, const char *msg)
{
- if (!ctx->ff_debug_enabled || !ctx->ff_debug_stream) return FF_RESULT_WARN_DEBUG_DISABLED;
-
- ctx->ff_debug_stream->write(msg, ff_strlen(msg), ctx->ff_debug_stream->user);
-
+ if (!ctx->ff_debug_enabled) return FF_RESULT_WARN_DEBUG_DISABLED;
+ if (!ctx->ff_debug_stream.write) return FF_RESULT_WARN_DEBUG_DISABLED;
+ ctx->ff_debug_stream.write(msg, ff_strlen(msg), ctx->ff_debug_stream.user);
return FF_RESULT_OK;
}