From 652f57a8ad22d3b0194df708c7049be37d7d3074 Mon Sep 17 00:00:00 2001 From: mquinson Date: Tue, 11 Sep 2007 08:49:27 +0000 Subject: [PATCH] Stop build the log strings on the stack: we are multi-threaded now, and this is like asking for problems git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@4147 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/xbt/log.c | 4 ++-- src/xbt/xbt_log_layout_format.c | 10 ++++------ src/xbt/xbt_log_layout_simple.c | 13 +++++-------- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/xbt/log.c b/src/xbt/log.c index d27bdd61ea..70f2c13f88 100644 --- a/src/xbt/log.c +++ b/src/xbt/log.c @@ -581,8 +581,8 @@ void _xbt_log_event_log( xbt_log_event_t ev, const char *fmt, ...) { xbt_log_appender_t appender = cat->appender; if (appender != NULL) { xbt_assert1(cat->layout,"No valid layout for the appender of category %s",cat->name); - char *str= cat->layout->do_layout(cat->layout, ev, fmt); - appender->do_append(appender, str); + cat->layout->do_layout(cat->layout, ev, fmt); + appender->do_append(appender, ev->buffer); } if (!cat->additivity) break; diff --git a/src/xbt/xbt_log_layout_format.c b/src/xbt/xbt_log_layout_format.c index 86c34f6c78..2407d59cb9 100644 --- a/src/xbt/xbt_log_layout_format.c +++ b/src/xbt/xbt_log_layout_format.c @@ -17,10 +17,9 @@ extern const char *xbt_log_priority_names[7]; -static char *xbt_log_layout_format_doit(xbt_log_layout_t l, - xbt_log_event_t ev, - const char *msg_fmt) { - static char res[2048]; +static void xbt_log_layout_format_doit(xbt_log_layout_t l, + xbt_log_event_t ev, + const char *msg_fmt) { static double begin_of_time = -1; char *p,*q; int precision=-1; @@ -28,7 +27,7 @@ static char *xbt_log_layout_format_doit(xbt_log_layout_t l, if (begin_of_time<0) begin_of_time=gras_os_time(); - p = res; + p = ev->buffer; q = l->data; while (*q != '\0') { @@ -210,7 +209,6 @@ static char *xbt_log_layout_format_doit(xbt_log_layout_t l, } } *p = '\0'; - return res; } static void xbt_log_layout_format_free(xbt_log_layout_t lay) { diff --git a/src/xbt/xbt_log_layout_simple.c b/src/xbt/xbt_log_layout_simple.c index 2a84a5d4e0..9185cb2e5d 100644 --- a/src/xbt/xbt_log_layout_simple.c +++ b/src/xbt/xbt_log_layout_simple.c @@ -15,11 +15,9 @@ extern const char *xbt_log_priority_names[7]; - -static char *xbt_log_layout_simple_doit(xbt_log_layout_t l, - xbt_log_event_t ev, - const char *fmt) { - static char res[1024]; +static void xbt_log_layout_simple_doit(xbt_log_layout_t l, + xbt_log_event_t ev, + const char *fmt) { static double begin_of_time = -1; char *p; @@ -32,8 +30,8 @@ static char *xbt_log_layout_simple_doit(xbt_log_layout_t l, if (begin_of_time<0) begin_of_time=gras_os_time(); - p = res; - p += sprintf(res,"[");; + p = ev->buffer; + p += sprintf(p,"[");; /* Display the proc info if available */ if(strlen(xbt_procname())) p += sprintf(p,"%s:%s:(%d) ", @@ -57,7 +55,6 @@ static char *xbt_log_layout_simple_doit(xbt_log_layout_t l, /* End it */ p += sprintf(p, "\n"); - return res; } xbt_log_layout_t xbt_log_layout_simple_new(char *arg) { -- 2.20.1