talloc: talloc_set_flag/talloc_unset_flag and TALLOC_FLAG_WARN_MAY_REFERENCE
[rusty/samba.git] / lib / talloc / talloc.h
index cedc8d50f02fe94bc3703ea6a1067a3910c26a01..956dd4cdd860b177ddcbb2b6aa19671e5da37e86 100644 (file)
@@ -955,7 +955,7 @@ void *_talloc_reference_loc(const void *context, const void *ptr, const char *lo
  *     talloc_may_reference(a);
  * @endcode
  *
- * @see talloc_reference()
+ * @see talloc_reference(), talloc_set_flag()
  */
 void *talloc_may_reference(const void *ptr);
 
@@ -1711,6 +1711,26 @@ void talloc_enable_leak_report(void);
  */
 void talloc_enable_leak_report_full(void);
 
+#define TALLOC_FLAG_WARN_MAY_REFERENCE 0x1
+/**
+ * @brief Set a global flag which alters talloc's behavior.
+ *
+ * 0 is returned if the flag is known, -1 otherwise.
+ *
+ * Flag is one of the following:
+ * TALLOC_FLAG_WARN_MAY_REFERENCE:
+ *     Warn if talloc_reference() is called on a pointer without talloc_may_reference()
+ *     being called first.
+ */
+int talloc_set_flag(unsigned int flag);
+
+/**
+ * @brief Remove a global flag which alters talloc's behavior.
+ *
+ * 0 is returned if the flag is known, -1 otherwise.
+ */
+int talloc_unset_flag(unsigned int flag);
+
 /* @} ******************************************************************/
 
 void talloc_set_abort_fn(void (*abort_fn)(const char *reason));