]> jfr.im git - irc/atheme/libmowgli-2.git/commitdiff
Move logger buffer down to one page of memory and stop wasting room
authorPatrick McFarland <redacted>
Tue, 5 Feb 2013 10:45:41 +0000 (05:45 -0500)
committerPatrick McFarland <redacted>
Tue, 5 Feb 2013 10:45:41 +0000 (05:45 -0500)
src/libmowgli/core/logger.c
src/libmowgli/core/logger.h

index fc30f4666786a008d046972f1470c23e8c048d92..b0b7baf427412a261c09b9e745cd41cc010f6fe6 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "mowgli.h"
 
-char _mowgli_log_buf[65536];
+char _mowgli_log_buf[4096];
 mowgli_log_cb_t _mowgli_log_cb;
 
 void mowgli_log_cb_default(const char *buf) {
@@ -31,7 +31,7 @@ void mowgli_log_cb_default(const char *buf) {
 }
 
 void mowgli_log_bootstrap() {
-       _mowgli_log_buf[65535] = 0;
+       _mowgli_log_buf[4095] = 0;
        _mowgli_log_cb = mowgli_log_cb_default;
 }
 
@@ -44,17 +44,15 @@ void mowgli_log_set_cb(mowgli_log_cb_t callback) {
 /* TODO: remove next time there is a LIB_MAJOR bump */
 void mowgli_log_real(const char *file, int line, const char *func,
                const char *fmt, ...) {
-       int len = snprintf(_mowgli_log_buf, 65534, "(%s:%d %s): ", file, line,
+       int len = snprintf(_mowgli_log_buf, 4095, "(%s:%d %s): ", file, line,
                        func);
 
-       len--;
-
        char *buf = &_mowgli_log_buf[len];
 
        va_list va;
 
        va_start(va, fmt);
-       vsnprintf(buf, 65534 - len, fmt, va);
+       vsnprintf(buf, 4095 - len, fmt, va);
        va_end(va);
 
        _mowgli_log_cb(_mowgli_log_buf);
@@ -63,7 +61,7 @@ void mowgli_log_real(const char *file, int line, const char *func,
 /* TODO: remove next time there is a LIB_MAJOR bump */
 void mowgli_soft_assert_log(const char *asrt, const char *file, int line,
                const char *function) {
-       snprintf(_mowgli_log_buf, 65534,
+       snprintf(_mowgli_log_buf, 4095,
                        "(%s:%d %s): critical: Assertion '%s' failed.", file, line,
                        function, asrt);
 
index b9ee0b1e26db6c2441a75f23c94ed4d8a0405156..0dff31d936fd5cc5ac6b651c15efb6cbd5755cc8 100644 (file)
 
 typedef void (*mowgli_log_cb_t)(const char *);
 
-extern char _mowgli_log_buf[65536];
+extern char _mowgli_log_buf[4096];
 extern mowgli_log_cb_t _mowgli_log_cb;
 
 static inline void mowgli_log_prefix_real(const char *file, int line,
                const char *func, const char *prefix, const char *fmt, ...) {
 
-       int len = snprintf(_mowgli_log_buf, 65534, "(%s:%d %s): %s", file, line,
+       int len = snprintf(_mowgli_log_buf, 4095, "(%s:%d %s): %s", file, line,
                        func, prefix);
 
        char *buf = &_mowgli_log_buf[len];
@@ -66,7 +66,7 @@ static inline void mowgli_log_prefix_real(const char *file, int line,
        va_list va;
 
        va_start(va, fmt);
-       vsnprintf(buf, 65534 - len, fmt, va);
+       vsnprintf(buf, 4095 - len, fmt, va);
        va_end(va);
 
        _mowgli_log_cb(_mowgli_log_buf);