Skip to content

Commit

Permalink
htable: wrapped maco code in do {} while(0)
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Jan 27, 2025
1 parent 75994f4 commit 65a296b
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/modules/htable/ht_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 65a296b

Please sign in to comment.