summaryrefslogtreecommitdiff
path: root/source4/lib/talloc/talloc_guide.txt
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-01-16 23:21:52 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:08:55 -0500
commit7b79694eadc288592729567c3caa7c70f6662760 (patch)
treee33deb9389d3268095cf90ead49b44c359e1b8ea /source4/lib/talloc/talloc_guide.txt
parent0a5fd5421c02cb4df21eec30bf216df65cd7641b (diff)
downloadsamba-7b79694eadc288592729567c3caa7c70f6662760.tar.gz
samba-7b79694eadc288592729567c3caa7c70f6662760.tar.bz2
samba-7b79694eadc288592729567c3caa7c70f6662760.zip
r4790: added type checking helper macros in talloc. These take advantage of
the type names that talloc already keeps around for pointers, and allows the user to type check void* private pointers. It can also be used to implement polymorphism in C, as I'm sure someone would have pointed out to me sooner or later :-) (This used to be commit c283e1a3efac3a92e29a35856e20eb61ef4c221e)
Diffstat (limited to 'source4/lib/talloc/talloc_guide.txt')
-rw-r--r--source4/lib/talloc/talloc_guide.txt32
1 files changed, 32 insertions, 0 deletions
diff --git a/source4/lib/talloc/talloc_guide.txt b/source4/lib/talloc/talloc_guide.txt
index 30b7f64d67..927bd366fd 100644
--- a/source4/lib/talloc/talloc_guide.txt
+++ b/source4/lib/talloc/talloc_guide.txt
@@ -512,3 +512,35 @@ void *talloc_autofree_context(void);
This is a handy utility function that returns a talloc context
which will be automatically freed on program exit. This can be used
to reduce the noise in memory leak reports.
+
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+void *talloc_check_name(const void *ptr, const char *name);
+
+This function checks if a pointer has the specified name. If it does
+then the pointer is returned. It it doesn't then NULL is returned.
+
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+(type *)talloc_get_type(const void *ptr, type);
+
+This macro allows you to do type checking on talloc pointers. It is
+particularly useful for void* private pointers. It is equivalent to
+this:
+
+ (type *)talloc_check_name(ptr, #type)
+
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+talloc_set_type(const void *ptr, type);
+
+This macro allows you to force the name of a pointer to be a
+particular type. This can be used in conjunction with
+talloc_get_type() to do type checking on void* pointers.
+
+It is equivalent to this:
+ talloc_set_name_const(ptr, #type)
+
+
+
+