From: Victor Julien Date: Mon, 9 Dec 2013 15:20:30 +0000 (+0100) Subject: Convert Flow macros to inline functions X-Git-Tag: suricata-2.0beta2~56 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1476db44d93deeab4f55726145809982e34d0c0d;p=thirdparty%2Fsuricata.git Convert Flow macros to inline functions Convert FlowReference and FlowDeReference to inline functions for better readability and to aid static code analyzers. --- diff --git a/src/flow.h b/src/flow.h index 399caad20f..843e10790f 100644 --- a/src/flow.h +++ b/src/flow.h @@ -28,6 +28,7 @@ #include "util-var.h" #include "util-atomic.h" #include "detect-tag.h" +#include "util-optimize.h" #define FLOW_QUIET TRUE #define FLOW_VERBOSE FALSE @@ -507,19 +508,19 @@ static inline void FlowDecrUsecnt(Flow *f) (void) SC_ATOMIC_SUB(f->use_cnt, 1); } -#define FlowReference(dst_f_ptr, f) do { \ - if ((f) != NULL) { \ - FlowIncrUsecnt((f)); \ - *(dst_f_ptr) = f; \ - } \ - } while (0) +static inline void FlowReference(Flow **d, Flow *f) { + if (likely(f != NULL)) { + FlowIncrUsecnt(f); + *d = f; + } +} -#define FlowDeReference(src_f_ptr) do { \ - if (*(src_f_ptr) != NULL) { \ - FlowDecrUsecnt(*(src_f_ptr)); \ - *(src_f_ptr) = NULL; \ - } \ - } while (0) +static inline void FlowDeReference(Flow **d) { + if (likely(*d != NULL)) { + FlowDecrUsecnt(*d); + *d = NULL; + } +} int FlowClearMemory(Flow *,uint8_t );