svn commit: samba r6666 - in trunk/source: include lib
vlendec at samba.org
vlendec at samba.org
Sun May 8 15:24:44 GMT 2005
Author: vlendec
Date: 2005-05-08 15:24:44 +0000 (Sun, 08 May 2005)
New Revision: 6666
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=6666
Log:
A little extension for talloc_get_type: Abort if it's not the expected one,
this is a severe error anyway. Tridge, is this addition worthwile for Samba4?
Volker
Modified:
trunk/source/include/includes.h
trunk/source/lib/util.c
Changeset:
Modified: trunk/source/include/includes.h
===================================================================
--- trunk/source/include/includes.h 2005-05-08 15:22:24 UTC (rev 6665)
+++ trunk/source/include/includes.h 2005-05-08 15:24:44 UTC (rev 6666)
@@ -800,8 +800,12 @@
#include "tdb/tdb.h"
#include "tdb/spinlock.h"
#include "tdb/tdbutil.h"
-#define _SAMBA_BUILD_ 1
+
#include "talloc.h"
+/* And a little extension. Abort on type mismatch */
+#define talloc_get_type_abort(ptr, type) \
+ (type *)talloc_check_name_abort(ptr, #type)
+
#include "nt_status.h"
#include "ads.h"
#include "interfaces.h"
Modified: trunk/source/lib/util.c
===================================================================
--- trunk/source/lib/util.c 2005-05-08 15:22:24 UTC (rev 6665)
+++ trunk/source/lib/util.c 2005-05-08 15:24:44 UTC (rev 6666)
@@ -2628,6 +2628,29 @@
}
}
+/**********************************************************************
+ Extension to talloc_get_type: Abort on type mismatch
+***********************************************************************/
+
+void *talloc_check_name_abort(const void *ptr, const char *name)
+{
+ void *result;
+
+ if (ptr == NULL)
+ return NULL;
+
+ 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("aborting");
+ /* Keep the compiler happy */
+ return NULL;
+}
+
+
#ifdef __INSURE__
/*******************************************************************
More information about the samba-cvs
mailing list