[SCM] Samba Shared Repository - branch master updated -
release-4-0-0alpha7-136-gb00204a
Stefan Metzmacher
metze at samba.org
Tue Mar 3 17:25:54 GMT 2009
The branch, master has been updated
via b00204a46153a406a6c63792b1939bd3ad74ba71 (commit)
via b6f479d4413511fbd742e7c8464cec67501f539c (commit)
from 4b2955aa7dbcf06629d24d3ea35c6dfa8c4156b9 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit b00204a46153a406a6c63792b1939bd3ad74ba71
Author: Stefan Metzmacher <metze at samba.org>
Date: Tue Mar 3 18:03:57 2009 +0100
lib/util: remove samba specific talloc_get_type_abort()
metze
commit b6f479d4413511fbd742e7c8464cec67501f539c
Author: Stefan Metzmacher <metze at samba.org>
Date: Tue Mar 3 18:01:01 2009 +0100
talloc: add talloc_get_type_abort()
metze
-----------------------------------------------------------------------
Summary of changes:
lib/talloc/talloc.c | 24 ++++++++++++++++++++++++
lib/talloc/talloc.h | 2 ++
lib/util/util.c | 15 ---------------
lib/util/util.h | 7 -------
source3/include/includes.h | 4 ----
source3/include/proto.h | 1 -
6 files changed, 26 insertions(+), 27 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c
index 1f7e524..c472e9f 100644
--- a/lib/talloc/talloc.c
+++ b/lib/talloc/talloc.c
@@ -806,6 +806,30 @@ void *talloc_check_name(const void *ptr, const char *name)
return NULL;
}
+static void talloc_abort_type_missmatch(const char *location,
+ const char *name,
+ const char *expected)
+{
+ TALLOC_ABORT("Type missmatch");
+}
+
+void *_talloc_get_type_abort(const void *ptr, const char *name, const char *location)
+{
+ const char *pname;
+
+ if (unlikely(ptr == NULL)) {
+ talloc_abort_type_missmatch(location, NULL, name);
+ return NULL;
+ }
+
+ pname = talloc_get_name(ptr);
+ if (likely(pname == name || strcmp(pname, name) == 0)) {
+ return discard_const_p(void, ptr);
+ }
+
+ talloc_abort_type_missmatch(location, pname, name);
+ return NULL;
+}
/*
this is for compatibility with older versions of talloc
diff --git a/lib/talloc/talloc.h b/lib/talloc/talloc.h
index 5431971..002e06e 100644
--- a/lib/talloc/talloc.h
+++ b/lib/talloc/talloc.h
@@ -102,6 +102,7 @@ typedef void TALLOC_CTX;
#define talloc_set_type(ptr, type) talloc_set_name_const(ptr, #type)
#define talloc_get_type(ptr, type) (type *)talloc_check_name(ptr, #type)
+#define talloc_get_type_abort(ptr, type) (type *)_talloc_get_type_abort(ptr, #type, __location__)
#define talloc_find_parent_bytype(ptr, type) (type *)talloc_find_parent_byname(ptr, #type)
@@ -129,6 +130,7 @@ void *talloc_named(const void *context, size_t size,
void *talloc_named_const(const void *context, size_t size, const char *name);
const char *talloc_get_name(const void *ptr);
void *talloc_check_name(const void *ptr, const char *name);
+void *_talloc_get_type_abort(const void *ptr, const char *name, const char *location);
void *talloc_parent(const void *ptr);
const char *talloc_parent_name(const void *ptr);
void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2);
diff --git a/lib/util/util.c b/lib/util/util.c
index 1f31f55..0148bdb 100644
--- a/lib/util/util.c
+++ b/lib/util/util.c
@@ -541,21 +541,6 @@ void *malloc_array(size_t el_size, unsigned int count)
return realloc_array(NULL, el_size, count, false);
}
-_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;
-}
-
/**
Trim the specified elements off the front and back of a string.
**/
diff --git a/lib/util/util.h b/lib/util/util.h
index 1f6e3b1..defef12 100644
--- a/lib/util/util.h
+++ b/lib/util/util.h
@@ -767,13 +767,6 @@ 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)
-
bool unmap_file(void *start, size_t size);
void print_asc(int level, const uint8_t *buf,int len);
diff --git a/source3/include/includes.h b/source3/include/includes.h
index ca918b3..b48a755 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -584,10 +584,6 @@ struct smb_iconv_convenience *lp_iconv_convenience(void *lp_ctx);
#include "../lib/util/time.h"
#include "../lib/util/asn1.h"
-/* And a little extension. Abort on type mismatch */
-#define talloc_get_type_abort(ptr, type) \
- (type *)talloc_check_name_abort(ptr, #type)
-
#include "ads.h"
#include "ads_dns.h"
#include "interfaces.h"
diff --git a/source3/include/proto.h b/source3/include/proto.h
index e1eab8d..7811016 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1173,7 +1173,6 @@ bool mask_match_search(const char *string, const char *pattern, bool is_case_sen
bool mask_match_list(const char *string, char **list, int listLen, bool is_case_sensitive);
bool unix_wild_match(const char *pattern, const char *string);
bool name_to_fqdn(fstring fqdn, const char *name);
-void *talloc_check_name_abort(const void *ptr, const char *name);
void *talloc_append_blob(TALLOC_CTX *mem_ctx, void *buf, DATA_BLOB blob);
uint32 map_share_mode_to_deny_mode(uint32 share_access, uint32 private_options);
pid_t procid_to_pid(const struct server_id *proc);
--
Samba Shared Repository
More information about the samba-cvs
mailing list