Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Stop build the log strings on the stack: we are multi-threaded now, and this is like...
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 11 Sep 2007 08:49:27 +0000 (08:49 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 11 Sep 2007 08:49:27 +0000 (08:49 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@4147 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/xbt/log.c
src/xbt/xbt_log_layout_format.c
src/xbt/xbt_log_layout_simple.c

index d27bdd6..70f2c13 100644 (file)
@@ -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;
index 86c34f6..2407d59 100644 (file)
 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) {
index 2a84a5d..9185cb2 100644 (file)
 
 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) {