[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Wed Apr 18 04:00:03 MDT 2012


The branch, master has been updated
       via  c4c8845 Talloc doc: Fix a cut&paste error
       via  64fdcda Talloc doc: talloc_pool() when not enough memory in the pool
       via  75bcb28 Talloc doc: TALLOC_FREE_FILL
       via  f8b589b Talloc doc: talloc_set_log_stderr()
       via  cf7f461 Talloc doc: talloc_set_log_fn()
       via  73b0ed6 Talloc doc: talloc_set_abort_fn()
       via  30ca391 Talloc doc: talloc_asprintf_append_buffer()
       via  50689ae Talloc doc: talloc_strndup_append_buffer()
       via  c5243a4 Talloc doc: talloc_strndup_append()
       via  3502371 Talloc doc: talloc_strdup_append_buffer()
       via  b233173 Talloc doc: talloc_strdup_append()
      from  c69c07e dbcheck: added fix for incorrect RMD_FLAGS

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit c4c8845930bf4a89e93f63d201de577ed36d5775
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Apr 18 10:22:39 2012 +0200

    Talloc doc: Fix a cut&paste error
    
    Autobuild-User: Volker Lendecke <vl at samba.org>
    Autobuild-Date: Wed Apr 18 11:59:49 CEST 2012 on sn-devel-104

commit 64fdcda0c79acfaec0045743dab97c4a24360a20
Author: Pavel Březina <pbrezina at redhat.com>
Date:   Mon Apr 16 15:23:55 2012 +0200

    Talloc doc: talloc_pool() when not enough memory in the pool

commit 75bcb28a95219b1f7456f1a6dd418c821ca1bb62
Author: Pavel Březina <pbrezina at redhat.com>
Date:   Mon Apr 16 15:04:44 2012 +0200

    Talloc doc: TALLOC_FREE_FILL

commit f8b589b7935bae9f63493a26678219c7b1661114
Author: Pavel Březina <pbrezina at redhat.com>
Date:   Mon Apr 16 14:49:03 2012 +0200

    Talloc doc: talloc_set_log_stderr()
    
    Documents this function.

commit cf7f4612b5180238d9a28a1481e945c535d0af97
Author: Pavel Březina <pbrezina at redhat.com>
Date:   Mon Apr 16 14:47:16 2012 +0200

    Talloc doc: talloc_set_log_fn()
    
    Documents this function.

commit 73b0ed650a75759b546022a9f0a4c609a856353c
Author: Pavel Březina <pbrezina at redhat.com>
Date:   Mon Apr 16 14:43:37 2012 +0200

    Talloc doc: talloc_set_abort_fn()
    
    Documents this function.

commit 30ca3915e50a9d9f71a28b7779fce81f8b6453d5
Author: Pavel Březina <pbrezina at redhat.com>
Date:   Mon Apr 16 13:32:02 2012 +0200

    Talloc doc: talloc_asprintf_append_buffer()
    
    Explains the difference between _append and _append_buffer.

commit 50689aee380b5eea75c0dbb8aedaca0b45bdd5ae
Author: Pavel Březina <pbrezina at redhat.com>
Date:   Mon Apr 16 13:17:59 2012 +0200

    Talloc doc: talloc_strndup_append_buffer()
    
    Explains the difference between _append and _append_buffer.

commit c5243a499f735b4b999dfe4be59a3bec90c6d4b9
Author: Pavel Březina <pbrezina at redhat.com>
Date:   Mon Apr 16 13:12:41 2012 +0200

    Talloc doc: talloc_strndup_append()
    
    The destination string is reallocated instead of duplicating the result.

commit 3502371a34280abaa8332b4f45b405f609736bec
Author: Pavel Březina <pbrezina at redhat.com>
Date:   Mon Apr 16 12:59:22 2012 +0200

    Talloc doc: talloc_strdup_append_buffer()
    
    Explains the difference between _append and _append_buffer.

commit b233173f85a902d8b037d7a9ac8e069bd3ae1101
Author: Pavel Březina <pbrezina at redhat.com>
Date:   Mon Apr 16 12:44:08 2012 +0200

    Talloc doc: talloc_strdup_append()
    
    The destination string is reallocated instead of duplicating the result.

-----------------------------------------------------------------------

Summary of changes:
 lib/talloc/talloc.h |  162 +++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 151 insertions(+), 11 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/talloc/talloc.h b/lib/talloc/talloc.h
index 96c7e24..ebd2ab5 100644
--- a/lib/talloc/talloc.h
+++ b/lib/talloc/talloc.h
@@ -1,16 +1,16 @@
 #ifndef _TALLOC_H_
 #define _TALLOC_H_
-/* 
+/*
    Unix SMB/CIFS implementation.
    Samba temporary memory allocation functions
 
    Copyright (C) Andrew Tridgell 2004-2005
    Copyright (C) Stefan Metzmacher 2006
-   
+
      ** NOTE! The following LGPL license applies to the talloc
      ** library. This does NOT imply that all of Samba is released
      ** under the LGPL
-   
+
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
@@ -194,6 +194,11 @@ void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2);
  * talloc_set_log_stderr() for more information on talloc logging
  * functions.
  *
+ * If <code>TALLOC_FREE_FILL</code> environment variable is set,
+ * the memory occupied by the context is filled with the value of this variable.
+ * The value should be a numeric representation of the character you want to
+ * use.
+ *
  * talloc_free() operates recursively on its children.
  *
  * @param[in]  ptr      The chunk to be freed.
@@ -822,6 +827,10 @@ void *talloc_find_parent_bytype(const void *ptr, #type);
  * recursively. If you use the child of the talloc pool as a parent for
  * grand-children, their memory is also taken from the talloc pool.
  *
+ * If there is not enough memory in the pool to allocate the new child,
+ * it will create a new talloc chunk as if the parent was a normal talloc
+ * context.
+ *
  * If you talloc_free() children of a talloc pool, the memory is not given
  * back to the system. Instead, free(3) is only called if the talloc_pool()
  * itself is released with talloc_free().
@@ -1290,7 +1299,17 @@ void *talloc_realloc_fn(const void *context, void *ptr, size_t size);
 char *talloc_strdup(const void *t, const char *p);
 
 /**
- * @brief Append a string to given string and duplicate the result.
+ * @brief Append a string to given string.
+ *
+ * The destination string is reallocated to take
+ * <code>strlen(s) + strlen(a) + 1</code> characters.
+ *
+ * This functions sets the name of the new pointer to the new
+ * string. This is equivalent to:
+ *
+ * @code
+ *      talloc_set_name_const(ptr, ptr)
+ * @endcode
  *
  * @param[in]  s        The destination to append to.
  *
@@ -1299,11 +1318,31 @@ char *talloc_strdup(const void *t, const char *p);
  * @return              The duplicated string, NULL on error.
  *
  * @see talloc_strdup()
+ * @see talloc_strdup_append_buffer()
  */
 char *talloc_strdup_append(char *s, const char *a);
 
 /**
- * @brief Append a string to a given buffer and duplicate the result.
+ * @brief Append a string to a given buffer.
+ *
+ * This is a more efficient version of talloc_strdup_append(). It determines the
+ * length of the destination string by the size of the talloc context.
+ *
+ * Use this very carefully as it produces a different result than
+ * talloc_strdup_append() when a zero character is in the middle of the
+ * destination string.
+ *
+ * @code
+ *      char *str_a = talloc_strdup(NULL, "hello world");
+ *      char *str_b = talloc_strdup(NULL, "hello world");
+ *      str_a[5] = str_b[5] = '\0'
+ *
+ *      char *app = talloc_strdup_append(str_a, ", hello");
+ *      char *buf = talloc_strdup_append_buffer(str_b, ", hello");
+ *
+ *      printf("%s\n", app); // hello, hello (app = "hello, hello")
+ *      printf("%s\n", buf); // hello (buf = "hello\0world, hello")
+ * @endcode
  *
  * @param[in]  s        The destination buffer to append to.
  *
@@ -1312,6 +1351,8 @@ char *talloc_strdup_append(char *s, const char *a);
  * @return              The duplicated string, NULL on error.
  *
  * @see talloc_strdup()
+ * @see talloc_strdup_append()
+ * @see talloc_array_length()
  */
 char *talloc_strdup_append_buffer(char *s, const char *a);
 
@@ -1338,8 +1379,17 @@ char *talloc_strdup_append_buffer(char *s, const char *a);
 char *talloc_strndup(const void *t, const char *p, size_t n);
 
 /**
- * @brief Append at most n characters of a string to given string and duplicate
- *        the result.
+ * @brief Append at most n characters of a string to given string.
+ *
+ * The destination string is reallocated to take
+ * <code>strlen(s) + strnlen(a, n) + 1</code> characters.
+ *
+ * This functions sets the name of the new pointer to the new
+ * string. This is equivalent to:
+ *
+ * @code
+ *      talloc_set_name_const(ptr, ptr)
+ * @endcode
  *
  * @param[in]  s        The destination string to append to.
  *
@@ -1351,12 +1401,31 @@ char *talloc_strndup(const void *t, const char *p, size_t n);
  * @return              The duplicated string, NULL on error.
  *
  * @see talloc_strndup()
+ * @see talloc_strndup_append_buffer()
  */
 char *talloc_strndup_append(char *s, const char *a, size_t n);
 
 /**
- * @brief Append at most n characters of a string to given buffer and duplicate
- *        the result.
+ * @brief Append at most n characters of a string to given buffer
+ *
+ * This is a more efficient version of talloc_strndup_append(). It determines
+ * the length of the destination string by the size of the talloc context.
+ *
+ * Use this very carefully as it produces a different result than
+ * talloc_strndup_append() when a zero character is in the middle of the
+ * destination string.
+ *
+ * @code
+ *      char *str_a = talloc_strdup(NULL, "hello world");
+ *      char *str_b = talloc_strdup(NULL, "hello world");
+ *      str_a[5] = str_b[5] = '\0'
+ *
+ *      char *app = talloc_strndup_append(str_a, ", hello", 7);
+ *      char *buf = talloc_strndup_append_buffer(str_b, ", hello", 7);
+ *
+ *      printf("%s\n", app); // hello, hello (app = "hello, hello")
+ *      printf("%s\n", buf); // hello (buf = "hello\0world, hello")
+ * @endcode
  *
  * @param[in]  s        The destination buffer to append to.
  *
@@ -1368,6 +1437,8 @@ char *talloc_strndup_append(char *s, const char *a, size_t n);
  * @return              The duplicated string, NULL on error.
  *
  * @see talloc_strndup()
+ * @see talloc_strndup_append()
+ * @see talloc_array_length()
  */
 char *talloc_strndup_append_buffer(char *s, const char *a, size_t n);
 
@@ -1475,6 +1546,25 @@ char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3
 /**
  * @brief Append a formatted string to another string.
  *
+ * This is a more efficient version of talloc_asprintf_append(). It determines
+ * the length of the destination string by the size of the talloc context.
+ *
+ * Use this very carefully as it produces a different result than
+ * talloc_asprintf_append() when a zero character is in the middle of the
+ * destination string.
+ *
+ * @code
+ *      char *str_a = talloc_strdup(NULL, "hello world");
+ *      char *str_b = talloc_strdup(NULL, "hello world");
+ *      str_a[5] = str_b[5] = '\0'
+ *
+ *      char *app = talloc_asprintf_append(str_a, "%s", ", hello");
+ *      char *buf = talloc_strdup_append_buffer(str_b, "%s", ", hello");
+ *
+ *      printf("%s\n", app); // hello, hello (app = "hello, hello")
+ *      printf("%s\n", buf); // hello (buf = "hello\0world, hello")
+ * @endcode
+ *
  * @param[in]  s        The string to append to
  *
  * @param[in]  fmt      The format string.
@@ -1482,6 +1572,9 @@ char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3
  * @param[in]  ...      The parameters used to fill fmt.
  *
  * @return              The formatted string, NULL on error.
+ *
+ * @see talloc_asprintf()
+ * @see talloc_asprintf_append()
  */
 char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
 
@@ -1685,12 +1778,59 @@ void talloc_enable_leak_report(void);
  */
 void talloc_enable_leak_report_full(void);
 
-/* @} ******************************************************************/
-
+/**
+ * @brief Set a custom "abort" function that is called on serious error.
+ *
+ * The default "abort" function is <code>abort()</code>.
+ *
+ * The "abort" function is called when:
+ *
+ * <ul>
+ *  <li>talloc_get_type_abort() fails</li>
+ *  <li>the provided pointer is not a valid talloc context</li>
+ *  <li>when the context meta data are invalid</li>
+ *  <li>when access after free is detected</li>
+ * </ul>
+ *
+ * Example:
+ *
+ * @code
+ * void my_abort(const char *reason)
+ * {
+ *      fprintf(stderr, "talloc abort: %s\n", reason);
+ *      abort();
+ * }
+ *
+ *      talloc_set_abort_fn(my_abort);
+ * @endcode
+ *
+ * @param[in]  abort_fn      The new "abort" function.
+ *
+ * @see talloc_set_log_fn()
+ * @see talloc_get_type()
+ */
 void talloc_set_abort_fn(void (*abort_fn)(const char *reason));
+
+/**
+ * @brief Set a logging function.
+ *
+ * @param[in]  log_fn      The logging function.
+ *
+ * @see talloc_set_log_stderr()
+ * @see talloc_set_abort_fn()
+ */
 void talloc_set_log_fn(void (*log_fn)(const char *message));
+
+/**
+ * @brief Set stderr as the output for logs.
+ *
+ * @see talloc_set_log_fn()
+ * @see talloc_set_abort_fn()
+ */
 void talloc_set_log_stderr(void);
 
+/* @} ******************************************************************/
+
 #if TALLOC_DEPRECATED
 #define talloc_zero_p(ctx, type) talloc_zero(ctx, type)
 #define talloc_p(ctx, type) talloc(ctx, type)


-- 
Samba Shared Repository


More information about the samba-cvs mailing list