Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reorganize structs to save a few bytes.
[simgrid.git] / src / xbt / log.c
index fdbe8b8..4bed85f 100644 (file)
@@ -473,8 +473,8 @@ xbt_log_layout_t xbt_log_default_layout = NULL; /* set in log_init */
 
 typedef struct {
   char *catname;
-  e_xbt_log_priority_t thresh;
   char *fmt;
+  e_xbt_log_priority_t thresh;
   int additivity;
   xbt_log_appender_t appender;
 } s_xbt_log_setting_t, *xbt_log_setting_t;
@@ -486,8 +486,7 @@ static void _free_setting(void *s)
   xbt_log_setting_t set = *(xbt_log_setting_t *) s;
   if (set) {
     free(set->catname);
-    if (set->fmt)
-      free(set->fmt);
+    free(set->fmt);
     free(set);
   }
 }
@@ -604,10 +603,11 @@ void xbt_log_postexit(void)
   log_cat_exit(&_XBT_LOGV(XBT_LOG_ROOT_CAT));
 }
 
-#define XBT_LOG_STATIC_BUFFER_SIZE 2048 /* Size of the static string in which we
-                                         * build the log string */
-#define XBT_LOG_DYNAMIC_BUFFER_SIZE 256 /* Minimum size of the dynamic string in
-                                         * which we build the log string */
+ /* Size of the static string in which we  build the log string */
+#define XBT_LOG_STATIC_BUFFER_SIZE 2048
+/* Minimum size of the dynamic string in which we build the log string
+   (should be greater than XBT_LOG_STATIC_BUFFER_SIZE) */
+#define XBT_LOG_DYNAMIC_BUFFER_SIZE 4096
 
 void _xbt_log_event_log(xbt_log_event_t ev, const char *fmt, ...)
 {
@@ -644,8 +644,7 @@ void _xbt_log_event_log(xbt_log_event_t ev, const char *fmt, ...)
     }
 
     /* The static buffer was too small, use a dynamically expanded one */
-    ev->buffer_size = MAX(2 * XBT_LOG_STATIC_BUFFER_SIZE,
-                          XBT_LOG_DYNAMIC_BUFFER_SIZE);
+    ev->buffer_size = XBT_LOG_DYNAMIC_BUFFER_SIZE;
     ev->buffer = xbt_malloc(ev->buffer_size);
     while (1) {
       int done;
@@ -1061,7 +1060,7 @@ void xbt_log_control_set(const char *control_string)
   /* split the string, and remove empty entries */
   set_strings = xbt_str_split_quoted(control_string);
 
-  if (xbt_dynar_length(set_strings) == 0) {     /* vicious user! */
+  if (xbt_dynar_is_empty(set_strings)) {     /* vicious user! */
     xbt_dynar_free(&set_strings);
     return;
   }