ソースを参照

htable: wrapped maco code in do {} while(0)

(cherry picked from commit 65a296b3478503ed3519ea9156d8f46f5cb9ce2a)
Daniel-Constantin Mierla 7 ヶ月 前
コミット
dfa9239cf6
1 ファイル変更15 行追加6 行削除
  1. 15 6
      src/modules/htable/ht_api.h

+ 15 - 6
src/modules/htable/ht_api.h

@@ -144,10 +144,19 @@ ht_cell_t *ht_iterator_get_current(str *iname);
 void ht_slot_lock(ht_t *ht, int idx);
 void ht_slot_unlock(ht_t *ht, int idx);
 
-#define HT_UPDATE_EXPIRE(ht, it, now)                               \
-	if(ht->updateexpire || (now && it->expire && it->expire < now)) \
-	it->expire = now + ht->htexpire
-#define HT_COPY_EXPIRE(ht, it, now, src) \
-	HT_UPDATE_EXPIRE(ht, it, now);       \
-	else it->expire = src->expire
+#define HT_UPDATE_EXPIRE(ht, it, now)                                     \
+	do {                                                                  \
+		if(ht->updateexpire || (now && it->expire && it->expire < now)) { \
+			it->expire = now + ht->htexpire;                              \
+		}                                                                 \
+	} while(0)
+#define HT_COPY_EXPIRE(ht, it, now, src)                                  \
+	do {                                                                  \
+		if(ht->updateexpire || (now && it->expire && it->expire < now)) { \
+			it->expire = now + ht->htexpire;                              \
+		} else {                                                          \
+			it->expire = src->expire;                                     \
+		}                                                                 \
+	} while(0)
+
 #endif