about summary refs log tree commit diff
path: root/src/rt
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2011-01-14 13:41:39 -0800
committerGraydon Hoare <graydon@mozilla.com>2011-01-14 13:41:39 -0800
commitfe1a4ab23c6493d72e41b5ed8d87e7741e847154 (patch)
tree0e8d2ddadda85c63cb959a88ea8bea1c7f9ef6d1 /src/rt
parentbdcb9d9b531c8dc6962d854edfeeeeb9477b40b2 (diff)
downloadrust-fe1a4ab23c6493d72e41b5ed8d87e7741e847154.tar.gz
rust-fe1a4ab23c6493d72e41b5ed8d87e7741e847154.zip
Change log buffer butes to a symbolic const in runtime.
Diffstat (limited to 'src/rt')
-rw-r--r--src/rt/rust_builtin.cpp4
-rw-r--r--src/rt/rust_dom.cpp4
-rw-r--r--src/rt/rust_internal.h4
-rw-r--r--src/rt/rust_log.cpp4
-rw-r--r--src/rt/rust_srv.cpp10
5 files changed, 15 insertions, 11 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index 84111d826e7..a859c7b9d49 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -22,14 +22,14 @@ last_os_error(rust_task *task) {
         return NULL;
     }
 #elif defined(_GNU_SOURCE)
-    char cbuf[1024];
+    char cbuf[BUF_BYTES];
     char *buf = strerror_r(errno, cbuf, sizeof(cbuf));
     if (!buf) {
         task->fail(1);
         return NULL;
     }
 #else
-    char buf[1024];
+    char buf[BUF_BYTES];
     int err = strerror_r(errno, buf, sizeof(buf));
     if (err) {
         task->fail(1);
diff --git a/src/rt/rust_dom.cpp b/src/rt/rust_dom.cpp
index 4527955176c..356e9fe49ba 100644
--- a/src/rt/rust_dom.cpp
+++ b/src/rt/rust_dom.cpp
@@ -57,7 +57,7 @@ rust_dom::activate(rust_task *task) {
 
 void
 rust_dom::log(rust_task *task, uint32_t type_bits, char const *fmt, ...) {
-    char buf[256];
+    char buf[BUF_BYTES];
     if (_log.is_tracing(type_bits)) {
         va_list args;
         va_start(args, fmt);
@@ -69,7 +69,7 @@ rust_dom::log(rust_task *task, uint32_t type_bits, char const *fmt, ...) {
 
 void
 rust_dom::log(uint32_t type_bits, char const *fmt, ...) {
-    char buf[256];
+    char buf[BUF_BYTES];
     if (_log.is_tracing(type_bits)) {
         va_list args;
         va_start(args, fmt);
diff --git a/src/rt/rust_internal.h b/src/rt/rust_internal.h
index f008d9f6bdb..9a1b2ec001f 100644
--- a/src/rt/rust_internal.h
+++ b/src/rt/rust_internal.h
@@ -88,6 +88,10 @@ static size_t const TIME_SLICE_IN_MS = 10;
 
 static intptr_t const CONST_REFCOUNT = 0x7badface;
 
+// This accounts for logging buffers.
+
+static size_t const BUF_BYTES = 1024;
+
 // Every reference counted object should derive from this base class.
 
 template <typename T> struct rc_base {
diff --git a/src/rt/rust_log.cpp b/src/rt/rust_log.cpp
index 20f3f146a88..d0ba85de868 100644
--- a/src/rt/rust_log.cpp
+++ b/src/rt/rust_log.cpp
@@ -136,7 +136,7 @@ append_string(char *buffer, rust_log::ansi_color color,
 
 void
 rust_log::trace_ln(uint32_t thread_id, char *prefix, char *message) {
-    char buffer[1024] = "";
+    char buffer[BUF_BYTES] = "";
     _log_lock.lock();
     append_string(buffer, "%-34s", prefix);
     for (uint32_t i = 0; i < _indent; i++) {
@@ -158,7 +158,7 @@ rust_log::trace_ln(rust_task *task, char *message) {
 #else
     uint32_t thread_id = hash((uint32_t) pthread_self());
 #endif
-    char prefix[1024] = "";
+    char prefix[BUF_BYTES] = "";
     if (_dom && _dom->name) {
         append_string(prefix, "%04" PRIxPTR ":%.10s:",
                       thread_id, _dom->name);
diff --git a/src/rt/rust_srv.cpp b/src/rt/rust_srv.cpp
index a5fcde9b3a0..0453abce6cd 100644
--- a/src/rt/rust_srv.cpp
+++ b/src/rt/rust_srv.cpp
@@ -12,7 +12,7 @@ rust_srv::rust_srv() :
 }
 
 rust_srv::~rust_srv() {
-//    char msg[1024];
+//    char msg[BUF_BYTES];
 //    snprintf(msg, sizeof(msg), "~rust_srv %" PRIxPTR, (uintptr_t) this);
 //    log(msg);
 }
@@ -43,13 +43,13 @@ rust_srv::fatal(const char *expression,
     size_t line,
     const char *format,
     ...) {
-    char buf[1024];
+    char buf[BUF_BYTES];
     va_list args;
     va_start(args, format);
     vsnprintf(buf, sizeof(buf), format, args);
     va_end(args);
 
-    char msg[1024];
+    char msg[BUF_BYTES];
     snprintf(msg, sizeof(msg),
              "fatal, '%s' failed, %s:%d %s",
              expression, file, (int)line, buf);
@@ -63,13 +63,13 @@ rust_srv::warning(char const *expression,
     size_t line,
     const char *format,
     ...) {
-    char buf[1024];
+    char buf[BUF_BYTES];
     va_list args;
     va_start(args, format);
     vsnprintf(buf, sizeof(buf), format, args);
     va_end(args);
 
-    char msg[1024];
+    char msg[BUF_BYTES];
     snprintf(msg, sizeof(msg),
              "warning: '%s', at: %s:%d %s",
              expression, file, (int)line, buf);