[SCM] Samba Shared Repository - branch v4-0-test updated

Karolin Seeger kseeger at samba.org
Sun Mar 15 17:23:05 MDT 2015


The branch, v4-0-test has been updated
       via  786cbeb s3:configure: require external talloc >= 2.1.2
       via  28e014b talloc: version 2.1.2
       via  79f15e0 talloc: fix _talloc_total_limit_size prototype
       via  3cbf66c lib: talloc: Test suite for the new destructor reparent logic.
       via  1b584cf lib: talloc: Allow destructors to reparent the object they're called on.
       via  8194d06 lib: talloc: Fix bug when calling a destructor.
       via  6640cfa talloc:build: improve detection of srcdir
       via  8eb3271 talloc: version 2.1.1
       via  509dd16 talloc/tests: avoid some unused variable warnings
       via  243be7a talloc: fix compiler warning
       via  f2396a6 talloc: check for TALLOC_GET_TYPE_ABORT_NOOP
       via  51cc876 talloc: avoid a function call in TALLOC_FREE() if possible.
       via  61e6848 talloc: inline talloc_get_name()
       via  0886602 talloc: inline more static functions
       via  4419cad talloc: Tune talloc_vasprintf
       via  d9e00c6 talloc: Update flags in pytalloc-util pkgconfig file
       via  6e5df36 Add a basic guide on pytalloc.
       via  2d30bcb talloc: Add a warning to talloc_reference() documentation.
       via  2c3ca8f talloc: Test the pooled object
       via  eb093c2 talloc: Add talloc_pooled_object
       via  fb91890 talloc: Allow nested pools.
       via  040a3e1 talloc: Add a separate pool size
       via  e5ff3e1 talloc: Put pool-specific data before the chunk
       via  aa2a731 talloc: Introduce __talloc_with_prefix
       via  164fb45 talloc: Decouple the dual use of chunk->pool
       via  61c0ed7 Fix valgrind errors with memmove and talloc pools.
       via  571ac8c Add simple limited pool tests to test_memlimit().
       via  18e14d6 Remove talloc_memlimit_update(). No longer used.
       via  cf58b43 Inside _talloc_realloc(), keep track of size changes over malloc/realloc/free.
       via  e9f3ce8 Don't call talloc_memlimit_update() inside _talloc_realloc() when we're just manipulating pool members.
       via  2435334 Fix a conditional check. (size - tc->size > 0) is always true if size and tc->size are unsigned.
       via  378363f In _talloc_steal_internal(), correctly decrement the memory limit in the source, and increment in the destination.
       via  e17b670 Inside _talloc_free_internal(), always call talloc_memlimit_update_on_free() before we free the real memory.
       via  0aa59ad Update memory limits when we call free() on a pool.
       via  681728a Change __talloc() to only call talloc_memlimit_check()/talloc_memlimit_grow() on actual malloc allocation.
       via  a49237c Change _talloc_total_mem_internal() to ignore memory allocated from a pool when calculating limit size.
       via  ddde41c Remove magic TC_HDR_SIZE handling inside talloc_memlimit_check().
       via  079a5e6 Start to fix talloc memlimits with talloc pools.
       via  6afc7bc talloc: Fix a typo
       via  e762b71 talloc: only provide the --enable-talloc-compat1 in standalone build
       via  9935376 talloc: Simplify _talloc_free_poolmem a bit
       via  1828505 talloc: Do an early return
       via  5c2eade talloc: Avoid some "else" by doing early returns
       via  61150fb talloc: Fix nonblank line endings
       via  856220d talloc: Convert error cecking macros into fns
       via  07ca908 Add tests for talloc_memlimit
       via  1460f36 Add memory limiting capability to talloc
      from  594e911 smbd: Stop using vfs_Chdir after SMB_VFS_DISCONNECT.

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-0-test


- Log -----------------------------------------------------------------
commit 786cbeb335a687d1d2d5028e4c51fcca7d22c7da
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Mar 10 10:51:11 2015 +0100

    s3:configure: require external talloc >= 2.1.2
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11144
    Memory leak in SMB2 notify handling.
    
    Autobuild-User(v4-0-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-0-test): Mon Mar 16 00:22:31 CET 2015 on sn-devel-104

commit 28e014b37db0f1bfc8204f71be6a72e321bf5847
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Mar 9 09:07:24 2015 +0100

    talloc: version 2.1.2
    
    Changes:
    - Allow destructors to reparent the object
    - Allow destructors to remove itself
    - Build improvements
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Günther Deschner <gd at samba.org>
    (cherry picked from commit 7bef5e4f0e5ff4a4187f3d63e51a1725ff32b771)

commit 79f15e0f58bdb2e3ac9bbf3ae61c696abfdefd4a
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Jan 27 13:07:34 2015 +0100

    talloc: fix _talloc_total_limit_size prototype
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit 3929abfc6b5a3ae8a27da57d4dbee9524e3585e3)

commit 3cbf66c06770c33c1fe2ba4135eabc8c6ba95f9f
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Mar 3 17:12:32 2015 -0800

    lib: talloc: Test suite for the new destructor reparent logic.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ira Cooper <ira at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Sun Mar  8 20:52:43 CET 2015 on sn-devel-104
    
    (cherry picked from commit 6b0cecee1b864a0589836caf9f5f2892f8cb6926)

commit 1b584cf8aa420844216033f4f43ca16fd53eb0fe
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Mar 3 17:02:47 2015 -0800

    lib: talloc: Allow destructors to reparent the object they're called on.
    
    If a destructor returns failure (-1) when freeing a child, talloc
    must then reparent the child.
    
    Firstly it tries the owner of any reference, next the parent of the
    current object calling _talloc_free_children_internal(), and finally
    the null context in the last resort.
    
    If a destructor reparented its own object, which can be a very
    desirable thing to do (a destructor can make a decision it isn't
    time to die yet, and as the parent may be going away it might
    want to move itself to longer-term storage) then this new parent
    gets overwritten by the existing reparenting logic.
    
    This patch checks when freeing a child if it already reparented
    itself, and if it did doesn't then overwrite the new parent.
    
    Makes destructors more flexible.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ira Cooper <ira at samba.org>
    (cherry picked from commit cc4e5481ea060db7f6d8a83619d859b2e002eb90)

commit 8194d069e55914710656abc8fb9d16a1fb24eb1c
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Mar 5 12:48:47 2015 -0800

    lib: talloc: Fix bug when calling a destructor.
    
    If the destructor itself calls talloc_set_destructor()
    and returns -1, the new destructor set is overwritten
    by talloc.
    
    Dectect that and leave the new destructor in place.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ira Cooper <ira at samba.org>
    (cherry picked from commit 3289a5d84f73bf044e5767a6c47a3f7bf8357c08)

commit 6640cfa7594c2e3897d2186d5f0345cdeb11d987
Author: Michael Adam <obnox at samba.org>
Date:   Fri Jun 20 18:04:44 2014 +0200

    talloc:build: improve detection of srcdir
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit cc86b4107acebf56c7bb17f59dd358615aed57b7)

commit 8eb3271c0ba4c7225ac8ed48c3e40455c8c55ba4
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 15 14:53:49 2014 +0200

    talloc: version 2.1.1
    
    Changes:
    - documentation updates
    - a fix for pytalloc-util.pc
    - performance improvements here and there
    - fixed compiler warnings
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Fri May 16 19:51:26 CEST 2014 on sn-devel-104
    
    (cherry picked from commit b8e5b68de3cff8d16e4be07fdc2e780d2c3c5750)

commit 509dd16184fb584f2c3f0a2d0ef1da5822658ae8
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Feb 27 09:28:02 2014 +0100

    talloc/tests: avoid some unused variable warnings
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 8fbb81923ddf3449b4ad1fa1a562c9fab8c74103)

commit 243be7a5dd95cdb99baa87f7e9ec707b281f1114
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Nov 20 09:58:09 2013 +0100

    talloc: fix compiler warning
    
    This avoids the following warning when using:
    
    CFLAGS="-O3 -g -fstrict-overflow -Wstrict-overflow=5"
    
    ../talloc.c: In Funktion »talloc_is_parent«:
    ../talloc.c:2658:21: Warnung: assuming signed overflow does not occur when
    changing X +- C1 cmp C2 to X cmp C1 +- C2 [-Wstrict-overflow]
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit de822b58476093dc43c27577d2f7074541113cc5)

commit f2396a6ee2adcb9ab68e91995cbe44dac7381cea
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Dec 5 08:36:13 2013 +0100

    talloc: check for TALLOC_GET_TYPE_ABORT_NOOP
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit eb95fc8866dd1710b4cc2f4a4e1dc9867424def2)

commit 51cc8768d6421737624e08fb2c5305717586cc43
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Dec 4 15:35:37 2013 +0100

    talloc: avoid a function call in TALLOC_FREE() if possible.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit b9fcfc6399eab750880ee0b9806311dd351a8ff6)

commit 61e684859b25673589f44e684ef3e077e5d37d4b
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Dec 4 23:22:04 2013 +0100

    talloc: inline talloc_get_name()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 014eecd0b2aead3a160af0d864feddd53c85b580)

commit 0886602f5cbf4b6ad432c914df8577ae55e0949e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Nov 20 09:57:58 2013 +0100

    talloc: inline more static functions
    
    We need the code to be as fast as possible.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 3aa35354724b88acc63f6b4439f7203d10db4e90)

commit 4419cad8952ce90febb2fdffd5bc1f74623475c6
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jan 10 10:45:22 2014 +0100

    talloc: Tune talloc_vasprintf
    
    vsnprintf is significantly more expensive than memcpy. For the
    common case where the string we print is less than a kilobyte, avoid
    the second vsnprintf.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu May 15 12:49:14 CEST 2014 on sn-devel-104
    
    (cherry picked from commit 593c8103af5a5ed6b3c915369fed5b90efb42c25)

commit d9e00c66d4573fc3ed85ceb709786356703d4615
Author: Lukas Slebodnik <lslebodn at redhat.com>
Date:   Fri Apr 4 13:29:39 2014 +0200

    talloc: Update flags in pytalloc-util pkgconfig file
    
    After exapnding, @LIB_RPATH@ will be -Wl,-rpatch,/usr/local/lib if rpath is
    used on install. But "-Wl," will be passed to linker and should not be among
    CFLAGS. Other pkgconfig files have @LIB_RPATH@ in the right place.
        @see commit 735c1cd2da15167748e92ba6de48fdb5169db587
    
    Signed-off-by: Lukas Slebodnik <lslebodn at redhat.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Fri Apr  4 23:50:25 CEST 2014 on sn-devel-104
    
    (cherry picked from commit e1df75b5a965829db0c1f76673dcc824447b3ae7)

commit 6e5df3694fb1686b210750e7bf765d992bfe16d3
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Wed Nov 27 02:12:02 2013 +0000

    Add a basic guide on pytalloc.
    
    Signed-off-by: Jelmer Vernooij <jelmer at samba.org>
    Reviewed-By: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Jelmer Vernooij <jelmer at samba.org>
    Autobuild-Date(master): Thu Nov 28 02:24:45 CET 2013 on sn-devel-104
    
    (cherry picked from commit 91c1053413e1f309b2d5b215a423f37e3883aa91)

commit 2d30bcb5c6dfe9f33cb76c106afcb913f4bdbd59
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Oct 14 13:17:12 2013 +0200

    talloc: Add a warning to talloc_reference() documentation.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Kai Blin <kai at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Mon Oct 14 23:05:54 CEST 2013 on sn-devel-104
    
    (cherry picked from commit 2343df451a13115eebfd46f9247ec2ae8c3a85c0)

commit 2c3ca8f15dfbe38389650d4185ac7a9611162869
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Sep 6 15:30:38 2013 -0700

    talloc: Test the pooled object
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 256d10f5792a37d20cbb45f2af3f8578bd354110)

commit eb093c25cfac34752fae01132781455fc0df6f2f
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Sep 6 15:15:32 2013 -0700

    talloc: Add talloc_pooled_object
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit e82320e5197bcdd0330bc829c0963ad09854a36c)

commit fb918907b87b82b65533c60d59c63553b0c8ea8f
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Sep 6 14:52:28 2013 -0700

    talloc: Allow nested pools.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Signed-off-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 20ad6d7aa3dc5e7db4d886202f757ac1f68287d4)

commit 040a3e1e04cd36ac9f061096f3906cd1cd997c60
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Sep 6 14:20:20 2013 -0700

    talloc: Add a separate pool size
    
    This is necessary to allow talloc pools to be objects on their own. It
    is an incompatible change in the sense that talloc_get_size(pool) now
    returns 0 instead of the pool size. When the talloc_pooled_object()
    call is added, this will start to make sense again.
    
    Maybe we should add a talloc_pool_size call? Or is that overkill?
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit a3d9099d9a96b36df21ee0733adc5210438fe9dc)

commit e5ff3e1b10eb5833f23f852454073625a1bd847a
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Sep 6 14:08:43 2013 -0700

    talloc: Put pool-specific data before the chunk
    
    This is a preparation to make talloc pool real objects themselves.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Signed-off-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit b87c8fd435d1863d6efcec03830ecd85ddfcd7fb)

commit aa2a731d1b124044b195f2730fedeac099230a31
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Sep 6 12:18:26 2013 -0700

    talloc: Introduce __talloc_with_prefix
    
    This will allow to exchange the extra talloc pool header with the
    talloc_chunk structure
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Signed-off-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 9887f387a10e94f71790c0c3c7dc5f8cde7e4eb2)

commit 164fb45d5a1fb5d135061d6264ca1d468802ee71
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Sep 6 10:54:43 2013 -0700

    talloc: Decouple the dual use of chunk->pool
    
    If we want nested pools, we will have pools that are pool members. So
    we will have to have a separate "next object" pointer  for pools. As
    we have struct talloc_pool_chunk now, this additional pointer does not
    affect normal talloc objects.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 1334c745e1f2157b66e14f9d8b4f6f7750238717)

commit 61c0ed72181abcf4db6f716e41535b98ef1da07c
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 13:20:43 2013 -0700

    Fix valgrind errors with memmove and talloc pools.
    
    bin/smbtorture //127.0.0.1 local.talloc now runs with no valgrind errors.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: "Stefan (metze) Metzmacher" <metze at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Wed Aug 28 02:44:17 CEST 2013 on sn-devel-104
    
    (cherry picked from commit 617c647b8ef562ace589a11a15eb460e6db71f2a)

commit 571ac8c269d3874ab4a9bf98d24f424c283d0b15
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 13:09:03 2013 -0700

    Add simple limited pool tests to test_memlimit().
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit cbfc3efbfd4a3a6f3b031ce8ef375d37f2c545f3)

commit 18e14d6a3e87546e1f736ad8ac94209096a490a8
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 13:08:33 2013 -0700

    Remove talloc_memlimit_update(). No longer used.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit 3d0f717d437bb24f430fad788b9eb35e8fe8e0e8)

commit cf58b4307ccdb9c496dccce9c4198c1374cf62b8
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 13:07:04 2013 -0700

    Inside _talloc_realloc(), keep track of size changes over malloc/realloc/free.
    
    Replace the last use of talloc_memlimit_update() with talloc_memlimit_grow()/
    talloc_memlimit_shrink().
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit 8e2a543e088cac36a5b6bbab1a6be961fa00cc4d)

commit e9f3ce8e93e8f75bf701789665d044f267ddf1a1
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 13:03:27 2013 -0700

    Don't call talloc_memlimit_update() inside _talloc_realloc() when we're just manipulating pool members.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit 314508dd73105138d756f4ca3dfb65f1d368a9f7)

commit 2435334409d441e502535aa4b353cd7ef9174cf2
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 12:59:04 2013 -0700

    Fix a conditional check. (size - tc->size > 0) is always true if size and tc->size are unsigned.
    
    Replace with (size > tc->size).
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit 0fbcfcc824e474874c15d7c0b2ea0df408448906)

commit 378363f0c81fc3bf88fd2b4805ac59e3ccaaecdd
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 12:57:43 2013 -0700

    In _talloc_steal_internal(), correctly decrement the memory limit in the source, and increment in the destination.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit 43860293225d14ca2c339277b42f8705322463ab)

commit e17b67063bfe4ff8ba76b0308016d1e3c4ad8eb9
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 12:54:38 2013 -0700

    Inside _talloc_free_internal(), always call talloc_memlimit_update_on_free() before we free the real memory.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit 6bc190d6dd7fd0ab028c39c1463477a863f6943a)

commit 0aa59adbf33b77be35f85afad2fca043c2eab8be
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 12:51:20 2013 -0700

    Update memory limits when we call free() on a pool.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit 4dfde7d33e7ac6c94833ecc758baff487ab67e4e)

commit 681728af4fb9ac47eb9fee34b409b1cc8186153f
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 12:49:00 2013 -0700

    Change __talloc() to only call talloc_memlimit_check()/talloc_memlimit_grow() on actual malloc allocation.
    
    Don't check the memlimit if the allocation was successful from a pool. We already
    checked the memory limit when we created the pool.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit a4ebbe73b4b8dcab4d344e693ad9796ec8997f87)

commit a49237cbb92e52929232046fb05d62e7f66e2ac8
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 12:46:09 2013 -0700

    Change _talloc_total_mem_internal() to ignore memory allocated from a pool when calculating limit size.
    
    We must only count normal tallocs, or a talloc pool itself.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit 4159a78ed7eda340758e22286f16186987a20f2f)

commit ddde41cd74cf37cddd27b4a83f154134a291aa1a
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 12:43:50 2013 -0700

    Remove magic TC_HDR_SIZE handling inside talloc_memlimit_check().
    
    Callers already account for TC_HDR_SIZE, do not add it twice.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit 7a6beae68ee3f9a97e9e56f4e24a437839fb3e19)

commit 079a5e628b535d4cb94e71a1899021986f3b657d
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 12:36:23 2013 -0700

    Start to fix talloc memlimits with talloc pools.
    
    Add the functions:
    
    talloc_memlimit_grow(), talloc_memlimit_shrink(),
    talloc_memlimit_update_on_free().
    
    as replacements for talloc_memlimit_update().
    The interface to talloc_memlimit_update() is very
    hard to understand and use. The above functions
    are (to me) much clearer.
    
    The goal of these changes is to only update
    the memlimits on malloc/free/realloc, not
    on every pool allocation. That way we only
    count pool creation as allocation from any
    imposed limits, not allocation from an already
    created pool.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit fe790f6cbc9b888a8d613cfb515f0d0c76daad47)

commit 6afc7bc1e8444a3a2f3443ec8184af0d79ffde00
Author: Volker Lendecke <vl at samba.org>
Date:   Mon May 20 14:26:08 2013 +0200

    talloc: Fix a typo
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Kai Blin <kai at samba.org>
    
    Autobuild-User(master): Kai Blin <kai at samba.org>
    Autobuild-Date(master): Mon May 20 18:48:49 CEST 2013 on sn-devel-104
    
    (cherry picked from commit d7708fd360c1fa1e3111fd4df266b52c96cca196)

commit e762b71a488fb2a20d6248498b52dee1280eab53
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue May 7 14:15:35 2013 +0200

    talloc: only provide the --enable-talloc-compat1 in standalone build
    
    The compat library is already only built in standalone build,
    so we need the configure option also only in the standalone build.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    (cherry picked from commit 8a878ec74bd24180aa73cfb39ff4a6c3e72d9d0b)

commit 993537655626a419d1bb7335e5fa28226905d3af
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Apr 15 22:19:25 2013 +0200

    talloc: Simplify _talloc_free_poolmem a bit
    
    Early returns are easier to understand than "else if"
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Apr 18 22:50:42 CEST 2013 on sn-devel-104
    
    (cherry picked from commit 79fe1381a3a78ad2316343fc8c1c27360b46ebbf)

commit 18285059101b34d125149602954c105dcb0d8e7e
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Apr 15 22:12:50 2013 +0200

    talloc: Do an early return
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit a796e48b1dfe96b194f3a3a0d70e25c3ab92690d)

commit 5c2eadec328d966d33be806dea8885ff44b24487
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Apr 15 22:11:44 2013 +0200

    talloc: Avoid some "else" by doing early returns
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit ccf33dd0547f32104041c8611626f3e02e22cbe9)

commit 61150fb12de1941537154c792a6db4a00f47b6c4
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Apr 15 21:44:38 2013 +0200

    talloc: Fix nonblank line endings
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit d3928b0c8af01f7751191b81a72590ca35751a8c)

commit 856220d329f1b58a06c0dcb13acf6cfe9c4e69fc
Author: Simo Sorce <idra at samba.org>
Date:   Fri Oct 5 10:32:32 2012 -0400

    talloc: Convert error cecking macros into fns
    
    This will avoid 'surprise returns' and makes the code cleare to readers.
    These macros were complex enough to warrant a full function anyway not
    just for readability but also for debuggability.
    
    Thanks David for pointing out this issue.
    
    Autobuild-User(master): Simo Sorce <idra at samba.org>
    Autobuild-Date(master): Fri Oct  5 23:24:17 CEST 2012 on sn-devel-104
    
    (cherry picked from commit 36ea39edf8dd9ede756debaf9632f3ded2a51abb)

commit 07ca908935517e94f26ec8b4ec6e5811002b9bfa
Author: Simo Sorce <idra at samba.org>
Date:   Sat Sep 22 16:35:21 2012 -0400

    Add tests for talloc_memlimit
    
    Autobuild-User(master): Simo Sorce <idra at samba.org>
    Autobuild-Date(master): Fri Oct  5 07:36:38 CEST 2012 on sn-devel-104
    
    (cherry picked from commit 7d7e33c624875a9694fcebdde942147ac3bf5f74)

commit 1460f36607ec9e0fcfa6170bb33899197dd6ea5b
Author: Simo Sorce <idra at samba.org>
Date:   Sat Sep 22 16:15:47 2012 -0400

    Add memory limiting capability to talloc
    
    By calling talloc_set_memlimit() we can now set a max memory limit
    for a whole talloc hierarchy.
    ANy attempt to allocate memory beyond the max allowed for the whole
    hierarchy wil cause an allocation failure.
    
    Stealing memory correctly accounts for used memory in the old and the new
    hierarchy but exceeding the memory limit in the new parent will not cause
    a failure.
    
    (cherry picked from commit a33a78c302fde61fdb7a6e71669f19be2cf5c836)

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

Summary of changes:
 ...oc-util-2.0.6.sigs => pytalloc-util-2.0.8.sigs} |   0
 ...oc-util-2.0.6.sigs => pytalloc-util-2.1.0.sigs} |   0
 ...oc-util-2.0.6.sigs => pytalloc-util-2.1.1.sigs} |   0
 ...oc-util-2.0.6.sigs => pytalloc-util-2.1.2.sigs} |   0
 .../ABI/{talloc-2.0.3.sigs => talloc-2.0.8.sigs}   |   1 +
 .../ABI/{talloc-2.0.3.sigs => talloc-2.1.0.sigs}   |   2 +
 .../ABI/{talloc-2.0.3.sigs => talloc-2.1.1.sigs}   |   2 +
 .../ABI/{talloc-2.0.3.sigs => talloc-2.1.2.sigs}   |   2 +
 lib/talloc/pytalloc-util.pc.in                     |   4 +-
 lib/talloc/pytalloc.h                              |   3 +
 lib/talloc/pytalloc_guide.txt                      | 153 ++++
 lib/talloc/talloc.c                                | 839 ++++++++++++++++-----
 lib/talloc/talloc.h                                |  73 +-
 lib/talloc/testsuite.c                             | 356 +++++++++
 lib/talloc/wscript                                 |  14 +-
 source3/configure.in                               |   2 +-
 16 files changed, 1253 insertions(+), 198 deletions(-)
 copy lib/talloc/ABI/{pytalloc-util-2.0.6.sigs => pytalloc-util-2.0.8.sigs} (100%)
 copy lib/talloc/ABI/{pytalloc-util-2.0.6.sigs => pytalloc-util-2.1.0.sigs} (100%)
 copy lib/talloc/ABI/{pytalloc-util-2.0.6.sigs => pytalloc-util-2.1.1.sigs} (100%)
 copy lib/talloc/ABI/{pytalloc-util-2.0.6.sigs => pytalloc-util-2.1.2.sigs} (100%)
 copy lib/talloc/ABI/{talloc-2.0.3.sigs => talloc-2.0.8.sigs} (98%)
 copy lib/talloc/ABI/{talloc-2.0.3.sigs => talloc-2.1.0.sigs} (96%)
 copy lib/talloc/ABI/{talloc-2.0.3.sigs => talloc-2.1.1.sigs} (96%)
 copy lib/talloc/ABI/{talloc-2.0.3.sigs => talloc-2.1.2.sigs} (96%)
 create mode 100644 lib/talloc/pytalloc_guide.txt


Changeset truncated at 500 lines:

diff --git a/lib/talloc/ABI/pytalloc-util-2.0.6.sigs b/lib/talloc/ABI/pytalloc-util-2.0.8.sigs
similarity index 100%
copy from lib/talloc/ABI/pytalloc-util-2.0.6.sigs
copy to lib/talloc/ABI/pytalloc-util-2.0.8.sigs
diff --git a/lib/talloc/ABI/pytalloc-util-2.0.6.sigs b/lib/talloc/ABI/pytalloc-util-2.1.0.sigs
similarity index 100%
copy from lib/talloc/ABI/pytalloc-util-2.0.6.sigs
copy to lib/talloc/ABI/pytalloc-util-2.1.0.sigs
diff --git a/lib/talloc/ABI/pytalloc-util-2.0.6.sigs b/lib/talloc/ABI/pytalloc-util-2.1.1.sigs
similarity index 100%
copy from lib/talloc/ABI/pytalloc-util-2.0.6.sigs
copy to lib/talloc/ABI/pytalloc-util-2.1.1.sigs
diff --git a/lib/talloc/ABI/pytalloc-util-2.0.6.sigs b/lib/talloc/ABI/pytalloc-util-2.1.2.sigs
similarity index 100%
copy from lib/talloc/ABI/pytalloc-util-2.0.6.sigs
copy to lib/talloc/ABI/pytalloc-util-2.1.2.sigs
diff --git a/lib/talloc/ABI/talloc-2.0.3.sigs b/lib/talloc/ABI/talloc-2.0.8.sigs
similarity index 98%
copy from lib/talloc/ABI/talloc-2.0.3.sigs
copy to lib/talloc/ABI/talloc-2.0.8.sigs
index 6e236d5..15a9e95 100644
--- a/lib/talloc/ABI/talloc-2.0.3.sigs
+++ b/lib/talloc/ABI/talloc-2.0.8.sigs
@@ -43,6 +43,7 @@ talloc_report_full: void (const void *, FILE *)
 talloc_set_abort_fn: void (void (*)(const char *))
 talloc_set_log_fn: void (void (*)(const char *))
 talloc_set_log_stderr: void (void)
+talloc_set_memlimit: int (const void *, size_t)
 talloc_set_name: const char *(const void *, const char *, ...)
 talloc_set_name_const: void (const void *, const char *)
 talloc_show_parents: void (const void *, FILE *)
diff --git a/lib/talloc/ABI/talloc-2.0.3.sigs b/lib/talloc/ABI/talloc-2.1.0.sigs
similarity index 96%
copy from lib/talloc/ABI/talloc-2.0.3.sigs
copy to lib/talloc/ABI/talloc-2.1.0.sigs
index 6e236d5..eae12cc 100644
--- a/lib/talloc/ABI/talloc-2.0.3.sigs
+++ b/lib/talloc/ABI/talloc-2.1.0.sigs
@@ -4,6 +4,7 @@ _talloc_free: int (void *, const char *)
 _talloc_get_type_abort: void *(const void *, const char *, const char *)
 _talloc_memdup: void *(const void *, const void *, size_t, const char *)
 _talloc_move: void *(const void *, const void *)
+_talloc_pooled_object: void *(const void *, size_t, const char *, unsigned int, size_t)
 _talloc_realloc: void *(const void *, void *, size_t, const char *)
 _talloc_realloc_array: void *(const void *, void *, size_t, unsigned int, const char *)
 _talloc_reference_loc: void *(const void *, const void *, const char *)
@@ -43,6 +44,7 @@ talloc_report_full: void (const void *, FILE *)
 talloc_set_abort_fn: void (void (*)(const char *))
 talloc_set_log_fn: void (void (*)(const char *))
 talloc_set_log_stderr: void (void)
+talloc_set_memlimit: int (const void *, size_t)
 talloc_set_name: const char *(const void *, const char *, ...)
 talloc_set_name_const: void (const void *, const char *)
 talloc_show_parents: void (const void *, FILE *)
diff --git a/lib/talloc/ABI/talloc-2.0.3.sigs b/lib/talloc/ABI/talloc-2.1.1.sigs
similarity index 96%
copy from lib/talloc/ABI/talloc-2.0.3.sigs
copy to lib/talloc/ABI/talloc-2.1.1.sigs
index 6e236d5..eae12cc 100644
--- a/lib/talloc/ABI/talloc-2.0.3.sigs
+++ b/lib/talloc/ABI/talloc-2.1.1.sigs
@@ -4,6 +4,7 @@ _talloc_free: int (void *, const char *)
 _talloc_get_type_abort: void *(const void *, const char *, const char *)
 _talloc_memdup: void *(const void *, const void *, size_t, const char *)
 _talloc_move: void *(const void *, const void *)
+_talloc_pooled_object: void *(const void *, size_t, const char *, unsigned int, size_t)
 _talloc_realloc: void *(const void *, void *, size_t, const char *)
 _talloc_realloc_array: void *(const void *, void *, size_t, unsigned int, const char *)
 _talloc_reference_loc: void *(const void *, const void *, const char *)
@@ -43,6 +44,7 @@ talloc_report_full: void (const void *, FILE *)
 talloc_set_abort_fn: void (void (*)(const char *))
 talloc_set_log_fn: void (void (*)(const char *))
 talloc_set_log_stderr: void (void)
+talloc_set_memlimit: int (const void *, size_t)
 talloc_set_name: const char *(const void *, const char *, ...)
 talloc_set_name_const: void (const void *, const char *)
 talloc_show_parents: void (const void *, FILE *)
diff --git a/lib/talloc/ABI/talloc-2.0.3.sigs b/lib/talloc/ABI/talloc-2.1.2.sigs
similarity index 96%
copy from lib/talloc/ABI/talloc-2.0.3.sigs
copy to lib/talloc/ABI/talloc-2.1.2.sigs
index 6e236d5..eae12cc 100644
--- a/lib/talloc/ABI/talloc-2.0.3.sigs
+++ b/lib/talloc/ABI/talloc-2.1.2.sigs
@@ -4,6 +4,7 @@ _talloc_free: int (void *, const char *)
 _talloc_get_type_abort: void *(const void *, const char *, const char *)
 _talloc_memdup: void *(const void *, const void *, size_t, const char *)
 _talloc_move: void *(const void *, const void *)
+_talloc_pooled_object: void *(const void *, size_t, const char *, unsigned int, size_t)
 _talloc_realloc: void *(const void *, void *, size_t, const char *)
 _talloc_realloc_array: void *(const void *, void *, size_t, unsigned int, const char *)
 _talloc_reference_loc: void *(const void *, const void *, const char *)
@@ -43,6 +44,7 @@ talloc_report_full: void (const void *, FILE *)
 talloc_set_abort_fn: void (void (*)(const char *))
 talloc_set_log_fn: void (void (*)(const char *))
 talloc_set_log_stderr: void (void)
+talloc_set_memlimit: int (const void *, size_t)
 talloc_set_name: const char *(const void *, const char *, ...)
 talloc_set_name_const: void (const void *, const char *)
 talloc_show_parents: void (const void *, FILE *)
diff --git a/lib/talloc/pytalloc-util.pc.in b/lib/talloc/pytalloc-util.pc.in
index bc704b4..b7426bb 100644
--- a/lib/talloc/pytalloc-util.pc.in
+++ b/lib/talloc/pytalloc-util.pc.in
@@ -6,6 +6,6 @@ includedir=@includedir@
 Name: pytalloc-util
 Description: Utility functions for using talloc objects with Python
 Version: @TALLOC_VERSION@
-Libs: -L${libdir} -lpytalloc-util
-Cflags: @LIB_RPATH@ -I${includedir}
+Libs: @LIB_RPATH@ -L${libdir} -lpytalloc-util
+Cflags: -I${includedir}
 URL: http://talloc.samba.org/
diff --git a/lib/talloc/pytalloc.h b/lib/talloc/pytalloc.h
index 2d2c57b..5c3876e 100644
--- a/lib/talloc/pytalloc.h
+++ b/lib/talloc/pytalloc.h
@@ -29,7 +29,10 @@ typedef struct {
 	void *ptr;
 } pytalloc_Object;
 
+/* Return the PyTypeObject for pytalloc_Object. Returns a new reference. */
 PyTypeObject *pytalloc_GetObjectType(void);
+
+/* Check whether a specific object is a talloc Object. */
 int pytalloc_Check(PyObject *);
 
 /* Retrieve the pointer for a pytalloc_object. Like talloc_get_type() 
diff --git a/lib/talloc/pytalloc_guide.txt b/lib/talloc/pytalloc_guide.txt
new file mode 100644
index 0000000..755a52b
--- /dev/null
+++ b/lib/talloc/pytalloc_guide.txt
@@ -0,0 +1,153 @@
+Using talloc in Samba4
+======================
+
+.. contents::
+
+Jelmer Vernooij
+August 2013
+
+The most current version of this document is available at
+   http://samba.org/ftp/unpacked/talloc/pytalloc_guide.txt
+
+pytalloc is a small library that provides glue for wrapping
+talloc-allocated objects from C in Python objects.
+
+What is pytalloc, and what is it not?
+-------------------------------------
+
+pytalloc is merely a helper library - it provides a convenient base type object
+for objects that wrap talloc-maintained memory in C. It won't write your
+bindings for you but it will make it easier to write C bindings that involve
+talloc, and take away some of the boiler plate.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+pytalloc_Object
+
+This is the new base class that all Python objects that wrap talloc pointers
+derive from. It is itself a subclass of the "Object" type that all objects
+in Python derive from.
+
+Note that you will almost never create objects of the pytalloc_Object type
+itself, as they are just opaque pointers that can not be accessed from
+Python. A common pattern is other objects that subclass pytalloc_Object and
+rely on it for their memory management.
+
+Each `pytalloc_Object` wraps two core of information - a talloc context
+and a pointer. The pointer is the actual data that is wrapped. The talloc
+context is used for memory management purposes only; when the wrapping Python object
+goes away, it unlinks the talloc context. The talloc context pointer and the ptr
+can (and often do) have the same value.
+
+Each pytalloc_Object has a custom __repr__ implementation that
+describes that it is a talloc object and the location of the
+pointer it is wrapping. it also has a custom __cmp__/__eq__/__neq__ method that
+compares the pointers the object is wrapping rather than the objects
+themselves (since there can be multiple objects that wrap the same talloc
+pointer).
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+PyTypeObject *pytalloc_GetObjectType(void)
+
+Obtain a reference to the PyTypeObject for `pytalloc_Object`. The reference
+counter for the object will be incremented, so the caller will have to
+decrement it when it no longer needs it (using `Py_DECREF`).
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-
+int pytalloc_Check(PyObject *)
+
+Check whether a specific object is a talloc Object. Returns non-zero if it is
+a pytalloc_Object and zero otherwise.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+type *pytalloc_get_type(PyObject *py_obj, type)
+
+Retrieve the pointer from a `pytalloc_Object` py_obj. type should be a
+C type, similar to a type passed to `talloc_get_type`.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+pytalloc_get_ptr(PyObject *py_obj)
+
+Retrieve the pointer from a `pytalloc_Object` py_obj. There is no
+type checking - use `pytalloc_get_type` if possible.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+TALLOC_CTX *pytalloc_get_mem_ctx(PyObject *py_obj)
+
+Retrieve the talloc context associated with a pytalloc_Object.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+PyObject *pytalloc_steal_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr)
+
+Create a new Python wrapping object for a talloc pointer and context, with
+py_type as associated Python sub type object.
+
+This will *not* increment the reference counter for the talloc context,
+so the caller should make sure such an increment has happened. When the Python
+object goes away, it will unreference the talloc context.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+PyObject *pytalloc_steal(PyTypeObject *py_type, void *ptr)
+
+Create a new Python wrapping object for a talloc pointer and context, with
+py_type as associated Python sub type object.
+
+This will *not* increment the reference counter for the talloc context,
+so the caller should make sure such an increment has happened. When the Python
+object goes away, it will unreference the talloc context.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+PyObject *pytalloc_reference_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr)
+
+Create a new Python wrapping object for a talloc pointer and context, with
+py_type as associated Python sub type object.
+
+This will increment the reference counter for the talloc context.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+PyObject *pytalloc_reference(PyTypeObject *py_type, void *talloc_ptr)
+
+Create a new Python wrapping object for a talloc pointer, with
+py_type as associated Python sub type object. The pointer will also be used
+as the talloc context.
+
+This will increment the reference counter for the talloc context.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+PyObject *pytalloc_new(type, PyTypeObject *typeobj)
+
+Create a new, empty pytalloc_Object with the specified Python type object. type
+should be a C type, similar to talloc_new().
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+PyObject *pytalloc_CObject_FromTallocPtr(void *);
+
+Create a new pytalloc_Object for an abitrary talloc-maintained C pointer. This will
+use a generic VoidPtr Python type, which just provides an opaque object in
+Python. The caller is responsible for incrementing the talloc reference count before calling
+this function - it will dereference the talloc pointer when it is garbage collected.
+
+Debug function for talloc in Python
+-----------------------------------
+
+The "talloc" module in Python provides a couple of functions that can be used
+to debug issues with objects wrapped by pytalloc.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+report_full(obj?)
+
+Print a full report on a specific object or on all allocated objects by Python.
+Same behaviour as the `talloc_report_full()` function that is provided by
+C talloc.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+enable_null_tracking()
+
+This enables tracking of the NULL memory context without enabling leak
+reporting on exit. Useful for when you want to do your own leak
+reporting call via talloc_report_null_full().
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+pytalloc_total_blocks(obj?)
+
+Return the talloc block count for all allocated objects or a specific object if
+specified.
diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c
index 18ee548..c10fd53 100644
--- a/lib/talloc/talloc.c
+++ b/lib/talloc/talloc.c
@@ -1,4 +1,4 @@
-/* 
+/*
    Samba Unix SMB/CIFS implementation.
 
    Samba trivial allocation library - new interface
@@ -7,11 +7,11 @@
 
    Copyright (C) Andrew Tridgell 2004
    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
@@ -71,9 +71,10 @@
 #define TALLOC_FLAG_LOOP 0x02
 #define TALLOC_FLAG_POOL 0x04		/* This is a talloc pool */
 #define TALLOC_FLAG_POOLMEM 0x08	/* This is allocated in a pool */
+
 #define TALLOC_MAGIC_REFERENCE ((const char *)1)
 
-/* by default we abort when given a bad pointer (such as when talloc_free() is called 
+/* by default we abort when given a bad pointer (such as when talloc_free() is called
    on a pointer that came from malloc() */
 #ifndef TALLOC_ABORT
 #define TALLOC_ABORT(reason) abort()
@@ -227,8 +228,26 @@ struct talloc_reference_handle {
 	const char *location;
 };
 
+struct talloc_memlimit {
+	struct talloc_chunk *parent;
+	struct talloc_memlimit *upper;
+	size_t max_size;
+	size_t cur_size;
+};
+
+static inline bool talloc_memlimit_check(struct talloc_memlimit *limit, size_t size);
+static inline void talloc_memlimit_grow(struct talloc_memlimit *limit,
+				size_t size);
+static inline void talloc_memlimit_shrink(struct talloc_memlimit *limit,
+				size_t size);
+static inline void talloc_memlimit_update_on_free(struct talloc_chunk *tc);
+
+static inline void _talloc_set_name_const(const void *ptr, const char *name);
+
 typedef int (*talloc_destructor_t)(void *);
 
+struct talloc_pool_hdr;
+
 struct talloc_chunk {
 	struct talloc_chunk *next, *prev;
 	struct talloc_chunk *parent, *child;
@@ -239,17 +258,21 @@ struct talloc_chunk {
 	unsigned flags;
 
 	/*
-	 * "pool" has dual use:
-	 *
-	 * For the talloc pool itself (i.e. TALLOC_FLAG_POOL is set), "pool"
-	 * marks the end of the currently allocated area.
-	 *
-	 * For members of the pool (i.e. TALLOC_FLAG_POOLMEM is set), "pool"
+	 * limit semantics:
+	 * if 'limit' is set it means all *new* children of the context will
+	 * be limited to a total aggregate size ox max_size for memory
+	 * allocations.
+	 * cur_size is used to keep track of the current use
+	 */
+	struct talloc_memlimit *limit;
+
+	/*
+	 * For members of a pool (i.e. TALLOC_FLAG_POOLMEM is set), "pool"
 	 * is a pointer to the struct talloc_chunk of the pool that it was
 	 * allocated from. This way children can quickly find the pool to chew
 	 * from.
 	 */
-	void *pool;
+	struct talloc_pool_hdr *pool;
 };
 
 /* 16 byte alignment seems to keep everyone happy */
@@ -346,7 +369,7 @@ static inline struct talloc_chunk *talloc_chunk_from_ptr(const void *ptr)
 {
 	const char *pp = (const char *)ptr;
 	struct talloc_chunk *tc = discard_const_p(struct talloc_chunk, pp - TC_HDR_SIZE);
-	if (unlikely((tc->flags & (TALLOC_FLAG_FREE | ~0xF)) != TALLOC_MAGIC)) { 
+	if (unlikely((tc->flags & (TALLOC_FLAG_FREE | ~0xF)) != TALLOC_MAGIC)) {
 		if ((tc->flags & (~0xFFF)) == TALLOC_MAGIC_BASE) {
 			talloc_abort_magic(tc->flags & (~0xF));
 			return NULL;
@@ -437,49 +460,58 @@ _PUBLIC_ const char *talloc_parent_name(const void *ptr)
   memory footprint of each talloc chunk by those 16 bytes.
 */
 
-union talloc_pool_chunk {
-	/* This lets object_count nestle into 16-byte padding of talloc_chunk,
-	 * on 32-bit platforms. */
-	struct tc_pool_hdr {
-		struct talloc_chunk c;
-		unsigned int object_count;
-	} hdr;
-	/* This makes it always 16 byte aligned. */
-	char pad[TC_ALIGN16(sizeof(struct tc_pool_hdr))];
+struct talloc_pool_hdr {
+	void *end;
+	unsigned int object_count;
+	size_t poolsize;
 };
 
-static void *tc_pool_end(union talloc_pool_chunk *pool_tc)
+#define TP_HDR_SIZE TC_ALIGN16(sizeof(struct talloc_pool_hdr))
+
+static inline struct talloc_pool_hdr *talloc_pool_from_chunk(struct talloc_chunk *c)
 {
-	return (char *)pool_tc + TC_HDR_SIZE + pool_tc->hdr.c.size;
+	return (struct talloc_pool_hdr *)((char *)c - TP_HDR_SIZE);
 }
 
-static size_t tc_pool_space_left(union talloc_pool_chunk *pool_tc)
+static inline struct talloc_chunk *talloc_chunk_from_pool(struct talloc_pool_hdr *h)
 {
-	return (char *)tc_pool_end(pool_tc) - (char *)pool_tc->hdr.c.pool;
+	return (struct talloc_chunk *)((char *)h + TP_HDR_SIZE);
 }
 
-static void *tc_pool_first_chunk(union talloc_pool_chunk *pool_tc)
+static inline void *tc_pool_end(struct talloc_pool_hdr *pool_hdr)
 {
-	return pool_tc + 1;
+	struct talloc_chunk *tc = talloc_chunk_from_pool(pool_hdr);
+	return (char *)tc + TC_HDR_SIZE + pool_hdr->poolsize;
+}
+
+static inline size_t tc_pool_space_left(struct talloc_pool_hdr *pool_hdr)
+{
+	return (char *)tc_pool_end(pool_hdr) - (char *)pool_hdr->end;
 }
 
 /* If tc is inside a pool, this gives the next neighbour. */
-static void *tc_next_chunk(struct talloc_chunk *tc)
+static inline void *tc_next_chunk(struct talloc_chunk *tc)
 {
 	return (char *)tc + TC_ALIGN16(TC_HDR_SIZE + tc->size);
 }
 
+static inline void *tc_pool_first_chunk(struct talloc_pool_hdr *pool_hdr)
+{
+	struct talloc_chunk *tc = talloc_chunk_from_pool(pool_hdr);
+	return tc_next_chunk(tc);
+}
+
 /* Mark the whole remaining pool as not accessable */
-static void tc_invalidate_pool(union talloc_pool_chunk *pool_tc)
+static inline void tc_invalidate_pool(struct talloc_pool_hdr *pool_hdr)
 {
-	size_t flen = tc_pool_space_left(pool_tc);
+	size_t flen = tc_pool_space_left(pool_hdr);
 
 	if (unlikely(talloc_fill.enabled)) {
-		memset(pool_tc->hdr.c.pool, talloc_fill.fill_value, flen);
+		memset(pool_hdr->end, talloc_fill.fill_value, flen);
 	}
 
 #if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_NOACCESS)
-	VALGRIND_MAKE_MEM_NOACCESS(pool_tc->hdr.c.pool, flen);
+	VALGRIND_MAKE_MEM_NOACCESS(pool_hdr->end, flen);
 #endif
 }
 
@@ -487,10 +519,10 @@ static void tc_invalidate_pool(union talloc_pool_chunk *pool_tc)
   Allocate from a pool
 */
 
-static struct talloc_chunk *talloc_alloc_pool(struct talloc_chunk *parent,
-					      size_t size)
+static inline struct talloc_chunk *talloc_alloc_pool(struct talloc_chunk *parent,
+						     size_t size, size_t prefix_len)
 {
-	union talloc_pool_chunk *pool_ctx = NULL;
+	struct talloc_pool_hdr *pool_hdr = NULL;
 	size_t space_left;
 	struct talloc_chunk *result;
 	size_t chunk_size;
@@ -500,49 +532,52 @@ static struct talloc_chunk *talloc_alloc_pool(struct talloc_chunk *parent,
 	}
 
 	if (parent->flags & TALLOC_FLAG_POOL) {
-		pool_ctx = (union talloc_pool_chunk *)parent;
+		pool_hdr = talloc_pool_from_chunk(parent);
 	}
 	else if (parent->flags & TALLOC_FLAG_POOLMEM) {
-		pool_ctx = (union talloc_pool_chunk *)parent->pool;
+		pool_hdr = parent->pool;
 	}
 
-	if (pool_ctx == NULL) {
+	if (pool_hdr == NULL) {
 		return NULL;
 	}
 
-	space_left = tc_pool_space_left(pool_ctx);
+	space_left = tc_pool_space_left(pool_hdr);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list