Преглед на файлове

* Move some common debug code

Bryan Drewery преди 16 години
родител
ревизия
43bd7ce9f2
променени са 3 файла, в които са добавени 7 реда и са изтрити 7 реда
  1. 1 0
      src/debug.h
  2. 3 3
      src/egg_timer.c
  3. 3 4
      src/net.c

+ 1 - 0
src/debug.h

@@ -13,6 +13,7 @@
 #undef DEBUG_CONTEXT
 
 #define GET_BUFS 5
+#define get_buf_inc() if (++current_get_buf == GET_BUFS) current_get_buf = 0;
 
 /*
  *    Handy aliases for memory tracking and core dumps

+ 3 - 3
src/egg_timer.c

@@ -253,10 +253,10 @@ static bool process_timer(egg_timer_t* timer) {
 		deleted = 1;
 	}
 
-	if (timer->name)
+	if (timer->name) {
 		simple_snprintf(get_buf[current_get_buf], sizeof(get_buf[current_get_buf]), "Execing timer: %s", timer->name);
-	if (++current_get_buf == GET_BUFS)
-		current_get_buf = 0;
+		get_buf_inc();
+	}
 
 	callback(client_data);
 	return deleted;

+ 3 - 4
src/net.c

@@ -1486,11 +1486,10 @@ bool socket_run() {
   if (xx >= 0) {		/* Non-error */
     if ((idx = findanyidx(xx)) != -1) {
       if (likely(dcc[idx].type->activity)) {
-        if (buf[0])
+        if (buf[0]) {
           strlcpy(get_buf[current_get_buf], buf, sizeof(get_buf[current_get_buf]));
-
-        if (++current_get_buf == GET_BUFS)
-          current_get_buf = 0;
+          get_buf_inc();
+        }
 
         /* Traffic stats */
         if (dcc[idx].type->name) {