1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
Commit Graph

340 Commits

Author SHA1 Message Date
Jeremy Allison
0fbcfcc824 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@samba.org>
Reviewed-by: Simo Sorce <idra@samba.org>
2013-08-27 15:44:20 -07:00
Jeremy Allison
4386029322 In _talloc_steal_internal(), correctly decrement the memory limit in the source, and increment in the destination.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Simo Sorce <idra@samba.org>
2013-08-27 15:44:19 -07:00
Jeremy Allison
6bc190d6dd Inside _talloc_free_internal(), always call talloc_memlimit_update_on_free() before we free the real memory.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Simo Sorce <idra@samba.org>
2013-08-27 15:44:19 -07:00
Jeremy Allison
4dfde7d33e Update memory limits when we call free() on a pool.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Simo Sorce <idra@samba.org>
2013-08-27 15:44:19 -07:00
Jeremy Allison
a4ebbe73b4 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@samba.org>
Reviewed-by: Simo Sorce <idra@samba.org>
2013-08-27 15:44:19 -07:00
Jeremy Allison
4159a78ed7 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@samba.org>
Reviewed-by: Simo Sorce <idra@samba.org>
2013-08-27 15:44:19 -07:00
Jeremy Allison
7a6beae68e 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@samba.org>
Reviewed-by: Simo Sorce <idra@samba.org>
2013-08-27 15:44:19 -07:00
Jeremy Allison
fe790f6cbc 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@samba.org>
Reviewed-by: Simo Sorce <idra@samba.org>
2013-08-27 15:44:19 -07:00
Andrew Bartlett
cd4b413cb0 build: Remove autoconf build system
We are now confident that that waf build system meets enough of our needs
that we will work to improve it, rather than maintain two build systems.

Andrew Bartlett

Reviewed-by: Jelmer Vernooij <jelmer@samba.org>

Reviewed-by: David Disseldorp <ddiss@samba.org>
2013-05-28 12:17:10 +10:00
Volker Lendecke
d7708fd360 talloc: Fix a typo
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Kai Blin <kai@samba.org>

Autobuild-User(master): Kai Blin <kai@samba.org>
Autobuild-Date(master): Mon May 20 18:48:49 CEST 2013 on sn-devel-104
2013-05-20 18:48:49 +02:00
Stefan Metzmacher
8a878ec74b 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@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-05-14 19:55:58 +02:00
Volker Lendecke
79fe1381a3 talloc: Simplify _talloc_free_poolmem a bit
Early returns are easier to understand than "else if"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Apr 18 22:50:42 CEST 2013 on sn-devel-104
2013-04-18 22:50:42 +02:00
Volker Lendecke
a796e48b1d talloc: Do an early return
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2013-04-18 11:36:44 -07:00
Volker Lendecke
ccf33dd054 talloc: Avoid some "else" by doing early returns
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2013-04-18 11:36:28 -07:00
Volker Lendecke
d3928b0c8a talloc: Fix nonblank line endings
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2013-04-18 11:36:14 -07:00
Karolin Seeger
4af921fe88 lib/talloc: Move manpage to man/.
Trying to be more consistent.

Karolin

Reviewed-by: Andreas Schneider <asn@samba.org>
2012-12-03 14:35:11 +01:00
Karolin Seeger
174ab3542d docs: man talloc: Add missing meta data.
This avoids warnings during the waf build and removes "FIXME" entries from the
manpage.

Karolin

Reviewed-by: Andreas Schneider <asn@samba.org>
2012-11-29 13:41:43 +01:00
Simo Sorce
36ea39edf8 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@samba.org>
Autobuild-Date(master): Fri Oct  5 23:24:17 CEST 2012 on sn-devel-104
2012-10-05 23:24:17 +02:00
Simo Sorce
7d7e33c624 Add tests for talloc_memlimit
Autobuild-User(master): Simo Sorce <idra@samba.org>
Autobuild-Date(master): Fri Oct  5 07:36:38 CEST 2012 on sn-devel-104
2012-10-05 07:36:38 +02:00
Simo Sorce
a33a78c302 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.
2012-10-05 05:57:17 +02:00
Andreas Schneider
41cffa3c8b doc: Remove build/ from doxygen config or it will not work in brew.
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Sat Aug  4 16:31:22 CEST 2012 on sn-devel-104
2012-08-04 16:31:22 +02:00
Rusty Russell
4f331872bc talloc: don't allow a talloc_pool inside a talloc_pool.
We explicitly call free() on a pool which falls to zero, assuming it's
not inside another pool (we crash).  Check on creation and explicitly
document this case.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-07-18 04:54:31 +09:30
Rusty Russell
8893215aaf talloc: use a struct for pool headers.
This neatens the code a bit (we should do a similar thing for all the
TALLOC_CHUNK macros).

Two subtler changes:
(1) As a result of the struct, we actually pack object_count into the 
    talloc header on 32-bit platforms (since the header is 40 bytes, but
    needs to be 16-byte aligned).
(2) I avoid VALGRIND_MAKE_MEM_UNDEFINED on memmove when we resize the
    only entry in a pool; that's done later anyway.

With -O2 on my 11.04 Ubuntu 32-bit x86 laptop, the talloc_pool speed as
measured by testsuite.c actually increases 10%.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-07-18 04:53:31 +09:30
Björn Jacke
7abe51f840 talloc: remove unused variables
found by the IRIX compiler

Autobuild-User(master): Björn Jacke <bj@sernet.de>
Autobuild-Date(master): Thu Jul  5 23:50:54 CEST 2012 on sn-devel-104
2012-07-05 23:50:54 +02:00
Andrew Bartlett
ccb7642e5b build: Remove unused release scripts for talloc
These now use waf dist, and the script/librelease.sh script as a wrapper.

The mksyms.sh call in the source3/Makefile uses the copy in source3/script

Andrew Bartlett
2012-05-30 04:15:11 +02:00
Andreas Schneider
5909188492 talloc: Update doxygen config.
Autobuild-User: Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date: Mon May  7 21:13:15 CEST 2012 on sn-devel-104
2012-05-07 21:13:15 +02:00
Pavel Březina
20408286e2 doc: Remove latex to doxygen conversion leftovers in talloc.
Signed-off-by: Andreas Schneider <asn@samba.org>
2012-05-07 19:20:30 +02:00
Andreas Schneider
69526997e5 doc: Fixes for the talloc best practices tutorial. 2012-05-07 19:20:30 +02:00
Andreas Schneider
c1c9ab1c79 doc: Fixes for the talloc debugging tutorial. 2012-05-07 19:20:30 +02:00
Andreas Schneider
5a758f448d doc: Fixes for the talloc pool tutorial. 2012-05-07 19:20:29 +02:00
Andreas Schneider
79efc9d6e2 doc: Fixes for the talloc destructor tutorial. 2012-05-07 19:20:29 +02:00
Andreas Schneider
7d5565e22d doc: Fixes for the talloc dynamic type system tutorial. 2012-05-07 19:20:29 +02:00
Andreas Schneider
dc112dcee0 doc: Fixes for the talloc stealing tutorial. 2012-05-07 19:20:29 +02:00
Andreas Schneider
9423ac06aa doc: Fixes for the talloc context tutorial. 2012-05-07 19:20:29 +02:00
Pavel Březina
d99b7d0220 doc: Add talloc tutorial.
Signed-off-by: Andreas Schneider <asn@samba.org>
2012-05-07 19:20:29 +02:00
Volker Lendecke
8d5e6770f4 talloc: Fix copy&paste errors 2012-04-24 13:28:44 +02:00
Pavel Březina
bdeee2202d Talloc doc: talloc_strdup_append does not return duplicated string 2012-04-24 13:28:38 +02:00
Pavel Březina
9a474717b8 Talloc doc: when s == NULL in _append functions 2012-04-24 13:28:34 +02:00
Volker Lendecke
c4c8845930 Talloc doc: Fix a cut&paste error
Autobuild-User: Volker Lendecke <vl@samba.org>
Autobuild-Date: Wed Apr 18 11:59:49 CEST 2012 on sn-devel-104
2012-04-18 11:59:49 +02:00
Pavel Březina
64fdcda0c7 Talloc doc: talloc_pool() when not enough memory in the pool 2012-04-18 10:27:17 +02:00
Pavel Březina
75bcb28a95 Talloc doc: TALLOC_FREE_FILL 2012-04-18 10:27:16 +02:00
Pavel Březina
f8b589b793 Talloc doc: talloc_set_log_stderr()
Documents this function.
2012-04-18 10:27:16 +02:00
Pavel Březina
cf7f4612b5 Talloc doc: talloc_set_log_fn()
Documents this function.
2012-04-18 10:27:16 +02:00
Pavel Březina
73b0ed650a Talloc doc: talloc_set_abort_fn()
Documents this function.
2012-04-18 10:27:16 +02:00
Pavel Březina
30ca3915e5 Talloc doc: talloc_asprintf_append_buffer()
Explains the difference between _append and _append_buffer.
2012-04-18 10:27:16 +02:00
Pavel Březina
50689aee38 Talloc doc: talloc_strndup_append_buffer()
Explains the difference between _append and _append_buffer.
2012-04-18 10:27:16 +02:00
Pavel Březina
c5243a499f Talloc doc: talloc_strndup_append()
The destination string is reallocated instead of duplicating the result.
2012-04-18 10:27:15 +02:00
Pavel Březina
3502371a34 Talloc doc: talloc_strdup_append_buffer()
Explains the difference between _append and _append_buffer.
2012-04-18 10:27:15 +02:00
Pavel Březina
b233173f85 Talloc doc: talloc_strdup_append()
The destination string is reallocated instead of duplicating the result.
2012-04-18 10:27:15 +02:00
Stefan Metzmacher
91ffcdd5a9 talloc/testsuite: fix compiler warnings
metze

Autobuild-User: Stefan Metzmacher <metze@samba.org>
Autobuild-Date: Tue Jan 10 13:31:33 CET 2012 on sn-devel-104
2012-01-10 13:31:33 +01:00