new macro US_ONCE_FOR()

This commit is contained in:
Maxim Devaev
2024-03-29 01:02:36 +02:00
parent 4e1f62bfac
commit e0f09f65a1
6 changed files with 20 additions and 25 deletions

View File

@@ -72,14 +72,16 @@
(m_a > m_b ? m_a : m_b); \
})
#define US_ONCE(...) { \
const int m_reported = __LINE__; \
if (m_reported != once) { \
#define US_ONCE_FOR(x_once, x_value, ...) { \
const int m_reported = (x_value); \
if (m_reported != (x_once)) { \
__VA_ARGS__; \
once = m_reported; \
(x_once) = m_reported; \
} \
}
#define US_ONCE(...) US_ONCE_FOR(once, __LINE__, ##__VA_ARGS__)
INLINE char *us_strdup(const char *str) {
char *const new = strdup(str);