Loading src/common/compat.h +2 −0 Changes for src/common/compat.h: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -95,11 +95,13 @@ extern INLINE double U64_TO_DBL(uint64_t x) { #define ATTR_PURE __attribute__((pure)) #define ATTR_MALLOC __attribute__((malloc)) #define ATTR_NONNULL(x) __attribute__((nonnull x)) #define PREDICT(exp, val) __builtin_expect((exp), (val)) #else #define ATTR_NORETURN #define ATTR_PURE #define ATTR_MALLOC #define ATTR_NONNULL(x) #define PREDICT(exp, val) #endif /* ===== String compatibility */ Loading src/common/util.h +9 −3 Changes for src/common/util.h: 9 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -38,8 +38,13 @@ */ #error "Sorry; we don't support building with NDEBUG." #else #ifdef __GNUC__ #define PREDICT_FALSE(x) PREDICT((x) != ((typeof(x)) 0), 0) #else #define PREDICT_FALSE(x) !(x) #endif #define tor_assert(expr) do { \ if (!(expr)) { \ if (PREDICT_FALSE(expr)) { \ log(LOG_ERR, LD_BUG, "%s:%d: %s: Assertion %s failed; aborting.", \ _SHORT_FILE_, __LINE__, __func__, #expr); \ fprintf(stderr,"%s:%d %s: Assertion %s failed; aborting.\n", \ Loading Loading @@ -74,13 +79,14 @@ void *_tor_memdup(const void *mem, size_t len DMALLOC_PARAMS) extern int dmalloc_free(const char *file, const int line, void *pnt, const int func_id); #define tor_free(p) do { \ if (p) { \ if (PREDICT((p)!=NULL, 1) { \ dmalloc_free(_SHORT_FILE_, __LINE__, (p), 0); \ (p)=NULL; \ } \ } while (0) #else #define tor_free(p) do { if (p) {free(p); (p)=NULL;} } while (0) #define tor_free(p) do { if (PREDICT((p)!=NULL,1)) { free(p); (p)=NULL;} } \ while (0) #endif #define tor_malloc(size) _tor_malloc(size DMALLOC_ARGS) Loading Loading
src/common/compat.h +2 −0 Changes for src/common/compat.h: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -95,11 +95,13 @@ extern INLINE double U64_TO_DBL(uint64_t x) { #define ATTR_PURE __attribute__((pure)) #define ATTR_MALLOC __attribute__((malloc)) #define ATTR_NONNULL(x) __attribute__((nonnull x)) #define PREDICT(exp, val) __builtin_expect((exp), (val)) #else #define ATTR_NORETURN #define ATTR_PURE #define ATTR_MALLOC #define ATTR_NONNULL(x) #define PREDICT(exp, val) #endif /* ===== String compatibility */ Loading
src/common/util.h +9 −3 Changes for src/common/util.h: 9 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -38,8 +38,13 @@ */ #error "Sorry; we don't support building with NDEBUG." #else #ifdef __GNUC__ #define PREDICT_FALSE(x) PREDICT((x) != ((typeof(x)) 0), 0) #else #define PREDICT_FALSE(x) !(x) #endif #define tor_assert(expr) do { \ if (!(expr)) { \ if (PREDICT_FALSE(expr)) { \ log(LOG_ERR, LD_BUG, "%s:%d: %s: Assertion %s failed; aborting.", \ _SHORT_FILE_, __LINE__, __func__, #expr); \ fprintf(stderr,"%s:%d %s: Assertion %s failed; aborting.\n", \ Loading Loading @@ -74,13 +79,14 @@ void *_tor_memdup(const void *mem, size_t len DMALLOC_PARAMS) extern int dmalloc_free(const char *file, const int line, void *pnt, const int func_id); #define tor_free(p) do { \ if (p) { \ if (PREDICT((p)!=NULL, 1) { \ dmalloc_free(_SHORT_FILE_, __LINE__, (p), 0); \ (p)=NULL; \ } \ } while (0) #else #define tor_free(p) do { if (p) {free(p); (p)=NULL;} } while (0) #define tor_free(p) do { if (PREDICT((p)!=NULL,1)) { free(p); (p)=NULL;} } \ while (0) #endif #define tor_malloc(size) _tor_malloc(size DMALLOC_ARGS) Loading