]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fixed STUB_RETREF() implementation to return the right type.
authorAlex Rousskov <rousskov@measurement-factory.com>
Wed, 18 Nov 2015 05:34:33 +0000 (22:34 -0700)
committerAlex Rousskov <rousskov@measurement-factory.com>
Wed, 18 Nov 2015 05:34:33 +0000 (22:34 -0700)
Removed bogus STUB_RETREF() comment about memory leaks in _unreachable_ code.
Deprecated STUB_RETSTATREF() as essentially duplicating STUB_RETREF().

src/tests/STUB.h

index 4660bf0182d7848855f75c267a928c35287d46a1..406266c40a21a32195f114ac26ed0f4071a0df3b 100644 (file)
 
 /** macro to stub a function which returns a reference to dynamic
  *  Aborts unit tests requiring its definition with a message about the missing linkage
- *  This macro uses 'new x' to construct a stack vailable for the reference, may leak.
- *  \param x may be the type to define or a constructor call with parameter values
+ *  \param x underlying or "referred to" type
  */
-#define STUB_RETREF(x) { stub_fatal(STUB_API " required"); return new x; }
+#define STUB_RETREF(x) { stub_fatal(STUB_API " required"); return *(x *)nullptr; }
 
-/** macro to stub a function which returns a reference to static
- *  Aborts unit tests requiring its definition with a message about the missing linkage
- *  This macro uses static variable definition to avoid leaks.
- *  \param x  the type name to define
- */
-#define STUB_RETSTATREF(x) { stub_fatal(STUB_API " required"); static x v; return v; }
+/** Same as STUB_RETREF(). TODO: Remove */
+#define STUB_RETSTATREF(x) STUB_RETREF(x)
 
 #endif /* STUB */