Ignore:
Timestamp:
Nov 27, 2012, 4:56:06 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated vendor to 3.6.9

Location:
vendor/current/lib/talloc
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/lib/talloc/talloc.3.xml

    r740 r746  
    784784    <para>
    785785      This program is free software; you can redistribute it and/or modify
    786       it under the terms of the GNU General Public License as published by
    787       the Free Software Foundation; either version 3 of the License, or (at
    788       your option) any later version.
     786      it under the terms of the GNU Lesser General Public License as
     787      published by the Free Software Foundation; either version 3 of the
     788      License, or (at your option) any later version.
    789789    </para>
    790790    <para>
  • vendor/current/lib/talloc/talloc.c

    r740 r746  
    839839                if (tc->prev) tc->prev->next = tc->next;
    840840                if (tc->next) tc->next->prev = tc->prev;
     841                tc->prev = tc->next = NULL;
    841842        }
    842843
     
    926927                if (tc->prev) tc->prev->next = tc->next;
    927928                if (tc->next) tc->next->prev = tc->prev;
     929                tc->prev = tc->next = NULL;
    928930        }
    929931
     
    12521254                        if (p) new_parent = TC_PTR_FROM_CHUNK(p);
    12531255                }
    1254                 /* finding the parent here is potentially quite
    1255                    expensive, but the alternative, which is to change
    1256                    talloc to always have a valid tc->parent pointer,
    1257                    makes realloc more expensive where there are a
    1258                    large number of children.
    1259 
    1260                    The reason we need the parent pointer here is that
    1261                    if _talloc_free_internal() fails due to references
    1262                    or a failing destructor we need to re-parent, but
    1263                    the free call can invalidate the prev pointer.
    1264                 */
    1265                 if (new_parent == null_context && (tc->child->refs || tc->child->destructor)) {
    1266                         old_parent = talloc_parent_chunk(ptr);
    1267                 }
    12681256                if (unlikely(_talloc_free_internal(child, location) == -1)) {
    12691257                        if (new_parent == null_context) {
    1270                                 struct talloc_chunk *p = old_parent;
     1258                                struct talloc_chunk *p = talloc_parent_chunk(ptr);
    12711259                                if (p) new_parent = TC_PTR_FROM_CHUNK(p);
    12721260                        }
     
    12831271_PUBLIC_ void talloc_free_children(void *ptr)
    12841272{
     1273        struct talloc_chunk *tc_name = NULL;
    12851274        struct talloc_chunk *tc;
    12861275
     
    12911280        tc = talloc_chunk_from_ptr(ptr);
    12921281
     1282        /* we do not want to free the context name if it is a child .. */
     1283        if (likely(tc->child)) {
     1284                for (tc_name = tc->child; tc_name; tc_name = tc_name->next) {
     1285                        if (tc->name == TC_PTR_FROM_CHUNK(tc_name)) break;
     1286                }
     1287                if (tc_name) {
     1288                        _TLIST_REMOVE(tc->child, tc_name);
     1289                        if (tc->child) {
     1290                                tc->child->parent = tc;
     1291                        }
     1292                }
     1293        }
     1294
    12931295        _talloc_free_children_internal(tc, ptr, __location__);
     1296
     1297        /* .. so we put it back after all other children have been freed */
     1298        if (tc_name) {
     1299                if (tc->child) {
     1300                        tc->child->parent = NULL;
     1301                }
     1302                tc_name->parent = tc;
     1303                _TLIST_ADD(tc->child, tc_name);
     1304        }
    12941305}
    12951306
  • vendor/current/lib/talloc/talloc.h

    r740 r746  
    174174 * no modifications and return -1.
    175175 *
    176  * If this pointer has an additional parent when talloc_free() is called
    177  * then the memory is not actually released, but instead the most
    178  * recently established parent is destroyed. See talloc_reference() for
    179  * details on establishing additional parents.
    180  *
    181  * For more control on which parent is removed, see talloc_unlink()
    182  *
    183  * talloc_free() operates recursively on its children.
    184  *
    185  * From the 2.0 version of talloc, as a special case, talloc_free() is
    186  * refused on pointers that have more than one parent, as talloc would
    187  * have no way of knowing which parent should be removed. To free a
     176 * From version 2.0 and onwards, as a special case, talloc_free() is
     177 * refused on pointers that have more than one parent associated, as talloc
     178 * would have no way of knowing which parent should be removed. This is
     179 * different from older versions in the sense that always the reference to
     180 * the most recently established parent has been destroyed. Hence to free a
    188181 * pointer that has more than one parent please use talloc_unlink().
    189182 *
     
    201194 * talloc_set_log_stderr() for more information on talloc logging
    202195 * functions.
     196 *
     197 * talloc_free() operates recursively on its children.
    203198 *
    204199 * @param[in]  ptr      The chunk to be freed.
     
    234229 * talloc_free()s only the children, not the context itself.
    235230 *
    236  * @param[in]  ptr      The chunk that you want to free the children of.
     231 * A NULL argument is handled as no-op.
     232 *
     233 * @param[in]  ptr      The chunk that you want to free the children of
     234 *                      (NULL is allowed too)
    237235 */
    238236void talloc_free_children(void *ptr);
     
    403401 * @param[in]  new_ctx  The new parent context.
    404402 *
    405  * @param[in]  ptr      Pointer to the talloc chunk to move.
     403 * @param[in]  pptr     Pointer to the talloc chunk to move.
    406404 *
    407405 * @return              The pointer of the talloc chunk it has been moved to,
    408406 *                      NULL on error.
    409407 */
    410 void *talloc_move(const void *new_ctx, const void *ptr);
    411 #else
    412 #define talloc_move(ctx, ptr) (_TALLOC_TYPEOF(*(ptr)))_talloc_move((ctx),(void *)(ptr))
     408void *talloc_move(const void *new_ctx, void **pptr);
     409#else
     410#define talloc_move(ctx, pptr) (_TALLOC_TYPEOF(*(pptr)))_talloc_move((ctx),(void *)(pptr))
    413411void *_talloc_move(const void *new_ctx, const void *pptr);
    414412#endif
     
    703701 * @brief Assign a type to a talloc chunk.
    704702 *
    705  * This macro allows you to force the name of a pointer to be a particular type.
    706  * This can be used in conjunction with talloc_get_type() to do type checking on
    707  * void* pointers.
     703 * This macro allows you to force the name of a pointer to be of a particular
     704 * type. This can be used in conjunction with talloc_get_type() to do type
     705 * checking on void* pointers.
    708706 *
    709707 * It is equivalent to this:
     
    906904 *   cause this pointer to be freed if it runs out of parents.
    907905 *
    908  * - you can talloc_free() the pointer itself. That will destroy the
    909  *   most recently established parent to the pointer and leave the
    910  *   pointer as a child of its current parent.
     906 * - you can talloc_free() the pointer itself if it has at maximum one
     907 *   parent. This behaviour has been changed since the release of version
     908 *   2.0. Further informations in the description of "talloc_free".
    911909 *
    912910 * For more control on which parent to remove, see talloc_unlink()
     
    943941 * a direct parent of ptr.
    944942 *
    945  * Usually you can just use talloc_free() instead of talloc_unlink(), but
    946  * sometimes it is useful to have the additional control on which parent is
    947  * removed.
     943 * You can just use talloc_free() instead of talloc_unlink() if there
     944 * is at maximum one parent. This behaviour has been changed since the
     945 * release of version 2.0. Further informations in the description of
     946 * "talloc_free".
    948947 *
    949948 * @param[in]  context  The talloc parent to remove.
     
    993992 * @brief Get the size of a talloc chunk.
    994993 *
    995  * This function lets you know the amount of memory alloced so far by
     994 * This function lets you know the amount of memory allocated so far by
    996995 * this context. It does NOT account for subcontext memory.
    997996 * This can be used to calculate the size of an array.
     
    14541453 *
    14551454 * This function appends the given formatted string to the given string. Use
    1456  * this varient when the string in the current talloc buffer may have been
     1455 * this variant when the string in the current talloc buffer may have been
    14571456 * truncated in length.
    14581457 *
     
    15521551 *
    15531552 * This provides a more detailed report than talloc_report(). It will
    1554  * recursively print the ensire tree of memory referenced by the
     1553 * recursively print the entire tree of memory referenced by the
    15551554 * pointer. References in the tree are shown by giving the name of the
    15561555 * pointer that is referenced.
  • vendor/current/lib/talloc/talloc_guide.txt

    r740 r746  
    2727
    2828and the pointer X->name would be a "child" of the talloc context "X"
    29 which is itself a child of mem_ctx. So if you do talloc_free(mem_ctx)
     29which is itself a child of "mem_ctx". So if you do talloc_free(mem_ctx)
    3030then it is all destroyed, whereas if you do talloc_free(X) then just X
    3131and X->name are destroyed, and if you do talloc_free(X->name) then
     
    6565the underlying "malloc" is), as long as each thread uses different 
    6666memory contexts.
    67 If two threads uses the same context then they need to synchronize in 
     67If two threads use the same context then they need to synchronize in
    6868order to be safe. In particular:
    6969- when using talloc_enable_leak_report(), giving directly NULL as a 
     
    137137no modifications and returns -1.
    138138
    139 If this pointer has an additional parent when talloc_free() is called
    140 then the memory is not actually released, but instead the most
    141 recently established parent is destroyed. See talloc_reference() for
    142 details on establishing additional parents.
    143 
    144 For more control on which parent is removed, see talloc_unlink()
    145 
    146 talloc_free() operates recursively on its children.
    147 
    148 From the 2.0 version of talloc, as a special case, talloc_free() is
    149 refused on pointers that have more than one parent, as talloc would
    150 have no way of knowing which parent should be removed. To free a
     139From version 2.0 and onwards, as a special case, talloc_free() is
     140refused on pointers that have more than one parent associated, as talloc
     141would have no way of knowing which parent should be removed. This is
     142different from older versions in the sense that always the reference to
     143the most recently established parent has been destroyed. Hence to free a
    151144pointer that has more than one parent please use talloc_unlink().
    152145
     
    163156functions.
    164157
    165 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    166 int talloc_free_children(void *ptr);
     158talloc_free() operates recursively on its children.
     159
     160=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
     161void talloc_free_children(void *ptr);
    167162
    168163The talloc_free_children() walks along the list of all children of a
     
    170165itself.
    171166
     167A NULL argument is handled as no-op.
    172168
    173169=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
     
    191187    cause this pointer to be freed if it runs out of parents.
    192188
    193   - you can talloc_free() the pointer itself. That will destroy the
    194     most recently established parent to the pointer and leave the
    195     pointer as a child of its current parent.
     189  - you can talloc_free() the pointer itself if it has at maximum one
     190    parent. This behaviour has been changed since the release of version
     191    2.0. Further informations in the description of "talloc_free".
    196192
    197193For more control on which parent to remove, see talloc_unlink()
     
    209205is NULL, then the function will make no modifications and return -1.
    210206
    211 Usually you can just use talloc_free() instead of talloc_unlink(), but
    212 sometimes it is useful to have the additional control on which parent
    213 is removed.
    214 
     207You can just use talloc_free() instead of talloc_unlink() if there
     208is at maximum one parent. This behaviour has been changed since the
     209release of version 2.0. Further informations in the description of
     210"talloc_free".
    215211
    216212=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
     
    484480
    485481This provides a more detailed report than talloc_report(). It will
    486 recursively print the ensire tree of memory referenced by the
     482recursively print the entire tree of memory referenced by the
    487483pointer. References in the tree are shown by giving the name of the
    488484pointer that is referenced.
     
    643639The talloc_asprintf_append() function appends the given formatted
    644640string to the given string.
    645 Use this varient when the string in the current talloc buffer may
     641Use this variant when the string in the current talloc buffer may
    646642have been truncated in length.
    647643
     
    657653The talloc_asprintf_append() function appends the given formatted
    658654string to the end of the currently allocated talloc buffer.
    659 Use this varient when the string in the current talloc buffer has
     655Use this variant when the string in the current talloc buffer has
    660656not been changed.
    661657
     
    731727talloc_set_type(const void *ptr, type);
    732728
    733 This macro allows you to force the name of a pointer to be a
     729This macro allows you to force the name of a pointer to be of a
    734730particular type. This can be used in conjunction with
    735731talloc_get_type() to do type checking on void* pointers.
     
    742738talloc_get_size(const void *ctx);
    743739
    744 This function lets you know the amount of memory alloced so far by
     740This function lets you know the amount of memory allocated so far by
    745741this context. It does NOT account for subcontext memory.
    746742This can be used to calculate the size of an array.
     
    769765void talloc_set_log_stderr(void)
    770766
    771 This sets the talloc log function to write log messages to stderr
     767This sets the talloc log function to write log messages to stderr.
  • vendor/current/lib/talloc/testsuite.c

    r740 r746  
    13181318        talloc_report_full(root, stdout);
    13191319        talloc_free(root);
     1320        CHECK_BLOCKS("null_context", NULL, 2);
     1321        return true;
     1322}
     1323
     1324static bool test_free_children(void)
     1325{
     1326        void *root;
     1327        const char *p1, *p2, *name, *name2;
     1328
     1329        talloc_enable_null_tracking();
     1330        root = talloc_new(NULL);
     1331        p1 = talloc_strdup(root, "foo1");
     1332        p2 = talloc_strdup(p1, "foo2");
     1333
     1334        talloc_set_name(p1, "%s", "testname");
     1335        talloc_free_children(p1);
     1336        /* check its still a valid talloc ptr */
     1337        talloc_get_size(talloc_get_name(p1));
     1338        if (strcmp(talloc_get_name(p1), "testname") != 0) {
     1339                return false;
     1340        }
     1341
     1342        talloc_set_name(p1, "%s", "testname");
     1343        name = talloc_get_name(p1);
     1344        talloc_free_children(p1);
     1345        /* check its still a valid talloc ptr */
     1346        talloc_get_size(talloc_get_name(p1));
     1347        torture_assert("name", name == talloc_get_name(p1), "name ptr changed");
     1348        torture_assert("namecheck", strcmp(talloc_get_name(p1), "testname") == 0,
     1349                       "wrong name");
     1350        CHECK_BLOCKS("name1", p1, 2);
     1351
     1352        /* note that this does not free the old child name */
     1353        talloc_set_name_const(p1, "testname2");
     1354        name2 = talloc_get_name(p1);
     1355        /* but this does */
     1356        talloc_free_children(p1);
     1357        torture_assert("namecheck", strcmp(talloc_get_name(p1), "testname2") == 0,
     1358                       "wrong name");
     1359        CHECK_BLOCKS("name1", p1, 1);
     1360
     1361        talloc_report_full(root, stdout);
     1362        talloc_free(root);
    13201363        return true;
    13211364}
     
    13801423        test_reset();
    13811424        ret &= test_rusty();
     1425        test_reset();
     1426        ret &= test_free_children();
    13821427
    13831428        if (ret) {
Note: See TracChangeset for help on using the changeset viewer.