diff options
author | Jean-Baptiste Queru <jbq@google.com> | 2009-03-17 17:15:47 -0700 |
---|---|---|
committer | Jean-Baptiste Queru <jbq@google.com> | 2009-03-18 09:29:29 -0700 |
commit | 83b65486beffc7c86f24c428fbb7b50bbbe189f9 (patch) | |
tree | ab343e30dd96348d35b0957453fbf6b7b0bac56d /liblog | |
parent | 4a4c9f6f98055918f1ebff06b3cc1ed622c058fe (diff) | |
parent | e037fd7e193ecccbb5c0888e49f6d58c224bc11d (diff) | |
download | system_core-83b65486beffc7c86f24c428fbb7b50bbbe189f9.zip system_core-83b65486beffc7c86f24c428fbb7b50bbbe189f9.tar.gz system_core-83b65486beffc7c86f24c428fbb7b50bbbe189f9.tar.bz2 |
Merge commit 'remotes/korg/cupcake' into merge
Conflicts:
init/devices.c
libpixelflinger/Android.mk
Diffstat (limited to 'liblog')
-rw-r--r-- | liblog/fake_log_device.c | 22 | ||||
-rw-r--r-- | liblog/logd_write.c | 2 |
2 files changed, 16 insertions, 8 deletions
diff --git a/liblog/fake_log_device.c b/liblog/fake_log_device.c index d9d67b4..ed9d699 100644 --- a/liblog/fake_log_device.c +++ b/liblog/fake_log_device.c @@ -438,31 +438,38 @@ static void showLog(LogState *state, if (*p++ == '\n') numLines++; } if (p > msg && *(p-1) != '\n') numLines++; - + /* * Create an array of iovecs large enough to write all of * the lines with a prefix and a suffix. */ const size_t INLINE_VECS = 6; + const size_t MAX_LINES = ((size_t)~0)/(3*sizeof(struct iovec*)); struct iovec stackVec[INLINE_VECS]; struct iovec* vec = stackVec; - - numLines *= 3; // 3 iovecs per line. - if (numLines > INLINE_VECS) { + size_t numVecs; + + if (numLines > MAX_LINES) + numLines = MAX_LINES; + + numVecs = numLines*3; // 3 iovecs per line. + if (numVecs > INLINE_VECS) { vec = (struct iovec*)malloc(sizeof(struct iovec)*numLines); if (vec == NULL) { msg = "LOG: write failed, no memory"; - numLines = 3; + numVecs = 3; + numLines = 1; + vec = stackVec; } } - + /* * Fill in the iovec pointers. */ p = msg; struct iovec* v = vec; int totalLen = 0; - while (p < end) { + while (numLines > 0 && p < end) { if (prefixLen > 0) { v->iov_base = prefixBuf; v->iov_len = prefixLen; @@ -484,6 +491,7 @@ static void showLog(LogState *state, totalLen += suffixLen; v++; } + numLines -= 1; } /* diff --git a/liblog/logd_write.c b/liblog/logd_write.c index e40d2ce..80867d1 100644 --- a/liblog/logd_write.c +++ b/liblog/logd_write.c @@ -25,7 +25,7 @@ #include <stdlib.h> #include <stdarg.h> -#include <utils/logger.h> +#include <cutils/logger.h> #include <cutils/logd.h> #define LOG_BUF_SIZE 1024 |