[mammoth] Update dbgln to use sprintf
This commit is contained in:
parent
20dd43cdfb
commit
71a601362d
|
@ -10,6 +10,7 @@ target_include_directories(mammoth_lib
|
||||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
|
|
||||||
target_link_libraries(mammoth_lib
|
target_link_libraries(mammoth_lib
|
||||||
|
c
|
||||||
zion_lib)
|
zion_lib)
|
||||||
|
|
||||||
set_target_properties(mammoth_lib PROPERTIES
|
set_target_properties(mammoth_lib PROPERTIES
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <zerrors.h>
|
#include <zerrors.h>
|
||||||
|
|
||||||
void dbgln(const char*);
|
void dbgln(const char* fmt, ...);
|
||||||
|
|
||||||
// Checks that the code is ok.
|
// Checks that the code is ok.
|
||||||
// if not exits the process.
|
// if not exits the process.
|
||||||
|
|
|
@ -1,13 +1,29 @@
|
||||||
#include "include/mammoth/debug.h"
|
#include "include/mammoth/debug.h"
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <zcall.h>
|
#include <zcall.h>
|
||||||
#include <zerrors.h>
|
#include <zerrors.h>
|
||||||
|
|
||||||
void dbgln(const char* str) {
|
void dbgln_internal(const char* str) { // Safe to ignore the result since right
|
||||||
// Safe to ignore the result since right now this doesn't throw.
|
// now this doesn't throw.
|
||||||
uint64_t _ = ZDebug(str);
|
uint64_t _ = ZDebug(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dbgln(const char* fmt, ...) {
|
||||||
|
char str[1024];
|
||||||
|
va_list arg;
|
||||||
|
va_start(arg, fmt);
|
||||||
|
int ret = vsprintf(str, fmt, arg);
|
||||||
|
va_end(arg);
|
||||||
|
|
||||||
|
if (ret == -1 || ret > 1024) {
|
||||||
|
crash("Bad vsprintf", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
dbgln_internal(str);
|
||||||
|
}
|
||||||
|
|
||||||
void check(uint64_t code) {
|
void check(uint64_t code) {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case Z_OK:
|
case Z_OK:
|
||||||
|
|
Loading…
Reference in New Issue