summaryrefslogtreecommitdiff
path: root/lib/talloc/doc
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2012-05-07 11:56:39 +0200
committerAndreas Schneider <asn@samba.org>2012-05-07 19:20:30 +0200
commit69526997e5636211824f8c041a9e57d039cc62f4 (patch)
treeea3f58b466f8767efe43f41c3401bd19e482990d /lib/talloc/doc
parentc1c9ab1c79571dfa1ae0a9f92f401ea89a50ca0e (diff)
downloadsamba-69526997e5636211824f8c041a9e57d039cc62f4.tar.gz
samba-69526997e5636211824f8c041a9e57d039cc62f4.tar.bz2
samba-69526997e5636211824f8c041a9e57d039cc62f4.zip
doc: Fixes for the talloc best practices tutorial.
Diffstat (limited to 'lib/talloc/doc')
-rw-r--r--lib/talloc/doc/tutorial_bestpractices.dox20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/talloc/doc/tutorial_bestpractices.dox b/lib/talloc/doc/tutorial_bestpractices.dox
index 034d63aa11..3634446743 100644
--- a/lib/talloc/doc/tutorial_bestpractices.dox
+++ b/lib/talloc/doc/tutorial_bestpractices.dox
@@ -4,18 +4,18 @@
The following sections contain several best practices and good manners that were
found by the <a href="http://www.samba.org">Samba</a> and
<a href="https://fedorahosted.org/sssd">SSSD</a> developers over the years.
-These will help you to write better code, easier to debug and with as few
-(hopefully none) memory leaks as possible.
+These will help you to write code which is better, easier to debug and with as
+few (hopefully none) memory leaks as possible.
@section bp-hierarchy Keep the context hierarchy steady
The talloc is a hierarchy memory allocator. The hierarchy nature is what makes
-the programming more error proof. It makes the memory easier to manage and free.
-Therefore, the first thing we should have on our mind is: always project our
-data structures into the talloc context hierarchy.
+the programming more error proof. It makes the memory easier to manage and to
+free. Therefore, the first thing we should have on our mind is: always project
+your data structures into the talloc context hierarchy.
That means if we have a structure, we should always use it as a parent context
-for its elements. This way we will not encounter any troubles when freeing this
+for its elements. This way we will not encounter any troubles when freeing the
structure or when changing its parent. The same rule applies for arrays.
For example, the structure <code>user</code> from section @ref context-hierarchy
@@ -26,7 +26,7 @@ should be created with the context hierarchy illustrated on the next image.
@section bp-tmpctx Every function should use its own context
It is a good practice to create a temporary talloc context at the function
-beginning and free this context just before the return statement. All the data
+beginning and free the context just before the return statement. All the data
must be allocated on this context or on its children. This ensures that no
memory leaks are created as long as we do not forget to free the temporary
context.
@@ -99,8 +99,8 @@ using <code>NULL</code> as the parameter for <code>talloc_new()</code> function.
Take a look at the following example:
@code
-char * create_user_filter(TALLOC_CTX *mem_ctx,
- uid_t uid, const char *username)
+char *create_user_filter(TALLOC_CTX *mem_ctx,
+ uid_t uid, const char *username)
{
char *filter = NULL;
char *sanitized_username = NULL;
@@ -189,4 +189,4 @@ errno_t handle_request(TALLOC_CTX mem_ctx)
}
@endcode
-*/ \ No newline at end of file
+*/