|
@@ -47,14 +47,14 @@
|
|
|
|
|
|
/** Like assert(3), but send assertion failures to the log as well as to
|
|
/** Like assert(3), but send assertion failures to the log as well as to
|
|
* stderr. */
|
|
* stderr. */
|
|
-#define tor_assert(expr) do { \
|
|
+#define tor_assert(expr) STMT_BEGIN \
|
|
if (PREDICT_UNLIKELY(IS_FALSE_AS_INT(expr))) { \
|
|
if (PREDICT_UNLIKELY(IS_FALSE_AS_INT(expr))) { \
|
|
log(LOG_ERR, LD_BUG, "%s:%d: %s: Assertion %s failed; aborting.", \
|
|
log(LOG_ERR, LD_BUG, "%s:%d: %s: Assertion %s failed; aborting.", \
|
|
_SHORT_FILE_, __LINE__, __func__, #expr); \
|
|
_SHORT_FILE_, __LINE__, __func__, #expr); \
|
|
fprintf(stderr,"%s:%d %s: Assertion %s failed; aborting.\n", \
|
|
fprintf(stderr,"%s:%d %s: Assertion %s failed; aborting.\n", \
|
|
_SHORT_FILE_, __LINE__, __func__, #expr); \
|
|
_SHORT_FILE_, __LINE__, __func__, #expr); \
|
|
abort(); \
|
|
abort(); \
|
|
- } } while (0)
|
|
+ } STMT_END
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#ifdef USE_DMALLOC
|
|
#ifdef USE_DMALLOC
|
|
@@ -83,19 +83,19 @@ void _tor_free(void *mem);
|
|
#ifdef USE_DMALLOC
|
|
#ifdef USE_DMALLOC
|
|
extern int dmalloc_free(const char *file, const int line, void *pnt,
|
|
extern int dmalloc_free(const char *file, const int line, void *pnt,
|
|
const int func_id);
|
|
const int func_id);
|
|
-#define tor_free(p) do { \
|
|
+#define tor_free(p) STMT_BEGIN \
|
|
if (PREDICT_LIKELY((p)!=NULL)) { \
|
|
if (PREDICT_LIKELY((p)!=NULL)) { \
|
|
dmalloc_free(_SHORT_FILE_, __LINE__, (p), 0); \
|
|
dmalloc_free(_SHORT_FILE_, __LINE__, (p), 0); \
|
|
(p)=NULL; \
|
|
(p)=NULL; \
|
|
} \
|
|
} \
|
|
- } while (0)
|
|
+ STMT_END
|
|
#else
|
|
#else
|
|
-#define tor_free(p) do { \
|
|
+#define tor_free(p) STMT_BEGIN \
|
|
if (PREDICT_LIKELY((p)!=NULL)) { \
|
|
if (PREDICT_LIKELY((p)!=NULL)) { \
|
|
free(p); \
|
|
free(p); \
|
|
(p)=NULL; \
|
|
(p)=NULL; \
|
|
} \
|
|
} \
|
|
- } while (0)
|
|
+ STMT_END
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#define tor_malloc(size) _tor_malloc(size DMALLOC_ARGS)
|
|
#define tor_malloc(size) _tor_malloc(size DMALLOC_ARGS)
|