diff options
author | Andreas Schneider <asn@samba.org> | 2012-05-07 11:25:50 +0200 |
---|---|---|
committer | Andreas Schneider <asn@samba.org> | 2012-05-07 19:20:29 +0200 |
commit | 7d5565e22d0ad8994225da18ef025bfdfa56c245 (patch) | |
tree | 05ceca2e265013c191b61c9373cee8547393dc46 /lib | |
parent | dc112dcee058f2f1a211a50790f659a629ab2978 (diff) | |
download | samba-7d5565e22d0ad8994225da18ef025bfdfa56c245.tar.gz samba-7d5565e22d0ad8994225da18ef025bfdfa56c245.tar.bz2 samba-7d5565e22d0ad8994225da18ef025bfdfa56c245.zip |
doc: Fixes for the talloc dynamic type system tutorial.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/talloc/doc/tutorial_dts.dox | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/lib/talloc/doc/tutorial_dts.dox b/lib/talloc/doc/tutorial_dts.dox index 9065d7a1f0..62c425c408 100644 --- a/lib/talloc/doc/tutorial_dts.dox +++ b/lib/talloc/doc/tutorial_dts.dox @@ -1,5 +1,6 @@ /** @page libtalloc_dts Chapter 3: Dynamic type system + @section dts Dynamic type system Generic programming in the C language is very difficult. There is no inheritance @@ -31,10 +32,10 @@ void specific_function() Unfortunately, the type information is lost as a result of this type cast. The compiler cannot check the type during the compilation nor are we able to do it -at runtime. Providing an invalid data type to the callback will result -in unexpected behaviour (not necessarily a crash) of the application. This -mistake is usually hard to detect because it is not the first thing on the mind -of the developer. +at runtime. Providing an invalid data type to the callback will result in +unexpected behaviour (not necessarily a crash) of the application. This mistake +is usually hard to detect because it is not the first thing which comes the +mind. As we already know, every talloc context contains a name. This name is available at any time and it can be used to determine the type of a context even if we @@ -45,20 +46,20 @@ way of using it to simulate the dynamic type system is to set it directly to the type of the variable. It is recommended to use one of |talloc()| and |talloc_array()| (or its -variants) to create the context as they set its name to the name of the type -automatically. +variants) to create the context as they set its name to the name of the +given type automatically. -If we have a context with such a name, we can use two similar functions that do -both the type check and the type cast for us: +If we have a context with such as a name, we can use two similar functions that +do both the type check and the type cast for us: - talloc_get_type() - talloc_get_type_abort() @section dts-examples Examples -Below given is an example of generic programming with talloc - if we provide -invalid data to the callback, the program will be aborted. This is a sufficient -reaction for such an error in most applications. +The following example will show how generic programming with talloc is handled - +if we provide invalid data to the callback, the program will be aborted. This +is a sufficient reaction for such an error in most applications. @code void foo_callback(void *pvt) @@ -76,8 +77,8 @@ int do_foo() @endcode But what if we are creating a service application that should be running for the -uptime of a server? We may want to abort the application during the development -process (to make sure the error is not overlooked) but try to recover from the +uptime of a server, we may want to abort the application during the development +process (to make sure the error is not overlooked) and try to recover from the error in the customer release. This can be achieved by creating a custom abort function with a conditional build. @@ -105,4 +106,4 @@ if (str == NULL) { name[talloc_new: ../src/main.c:24] expected[char] */ @endcode -*/
\ No newline at end of file +*/ |