util: Add talloc_get_type_abort() call.
authorKai Blin <kai@samba.org>
Fri, 21 Mar 2008 21:27:02 +0000 (22:27 +0100)
committerKai Blin <kai@samba.org>
Wed, 2 Apr 2008 21:05:44 +0000 (23:05 +0200)
source/lib/util/util.c
source/lib/util/util.h

index 7b6bfeeb7b07ea07fc2c96734b9dd55a994318bf..b5bb75358e107e18e22383eddcaff0217c86a16f 100644 (file)
@@ -582,3 +582,18 @@ _PUBLIC_ void *realloc_array(void *ptr, size_t el_size, unsigned count)
        return realloc(ptr, el_size * count);
 }
 
+_PUBLIC_ void *talloc_check_name_abort(const void *ptr, const char *name)
+{
+        void *result;
+
+        result = talloc_check_name(ptr, name);
+        if (result != NULL)
+                return result;
+
+        DEBUG(0, ("Talloc type mismatch, expected %s, got %s\n",
+                  name, talloc_get_name(ptr)));
+        smb_panic("talloc type mismatch");
+        /* Keep the compiler happy */
+        return NULL;
+}
+
index 60c84376345845fa09a2251ed22e4a1ab3c2a287..3bf6b98d2fb3f247ce9800ab5b835aab271935c3 100644 (file)
@@ -803,4 +803,11 @@ bool pm_process( const char *fileName,
                  bool (*pfunc)(const char *, const char *, void *),
                                 void *userdata);
 
+/**
+ * Add-on to talloc_get_type
+ */
+_PUBLIC_ void *talloc_check_name_abort(const void *ptr, const char *name);
+#define talloc_get_type_abort(ptr, type) \
+       (type *)talloc_check_name_abort(ptr, #type)
+
 #endif /* _SAMBA_UTIL_H_ */