11 years agoccanlint: handle weird directories.
Rusty Russell [Tue, 1 Mar 2011 05:31:20 +0000 (16:01 +1030)]
ccanlint: handle weird directories.

David Gibson reports (and I confirmed) that running ccanlint in /tmp
causes an very uninformative segv.  Fix that, and add a more useful message,
as well as delaying recursing until we're confident there's code around.

11 years agoconfig.h: idempotent-wrap the generated config.h
Rusty Russell [Tue, 1 Mar 2011 05:30:05 +0000 (16:00 +1030)]
config.h: idempotent-wrap the generated config.h

11 years agoasort: handle !HAVE_NESTED_FUNCTIONS
Rusty Russell [Tue, 1 Mar 2011 05:29:40 +0000 (15:59 +1030)]

Andreas Schlick reports that PaX et. al. dislike trampolines, so open-code
qsort from glibc.

Interestingly, _quicksort from glibc seems to have a void * parameter, but
I can't find any information on it.

11 years agofailtest: fix locking code.
Rusty Russell [Tue, 1 Mar 2011 00:52:56 +0000 (11:22 +1030)]
failtest: fix locking code.

We need to get the locks back *after* the child runs.

11 years agofailtest: fix tracepath bug.
Rusty Russell [Tue, 1 Mar 2011 00:52:39 +0000 (11:22 +1030)]
failtest: fix tracepath bug.

Aborts on a short write with --tracepath.

11 years agotdb2: make tdb2 compile clean under -Wshadow.
Rusty Russell [Thu, 24 Feb 2011 05:33:46 +0000 (16:03 +1030)]
tdb2: make tdb2 compile clean under -Wshadow.

This isn't a general requirement for CCAN modules, but Samba uses it, so
make sure tdb2 doesn't upset it.

11 years agojmap,likely,tdb2: use CCAN_<MODNAME>_DEBUG instead of DEBUG.
Rusty Russell [Thu, 24 Feb 2011 05:09:32 +0000 (15:39 +1030)]
jmap,likely,tdb2: use CCAN_<MODNAME>_DEBUG instead of DEBUG.

Samba (for example) uses a DEBUG() macro, which triggers these heuristics.
Better to make it per-module anyway.

11 years agoccanlint: fix more potential segvs when reporting ccanlint errors.
Rusty Russell [Thu, 24 Feb 2011 02:50:01 +0000 (13:20 +1030)]
ccanlint: fix more potential segvs when reporting ccanlint errors.

When I changed score_file_error() to printf-style, I didn't audit all
the callers who were handing string literals.  I've finally done that;
I should have broken the compile by renaming it.

Rusty fails refactoring 101.
Reported-by: Andreas Schlick
11 years agoccan_tokenizer: update to be compatible with darray.
Joey Adams [Sat, 19 Feb 2011 10:53:04 +0000 (05:53 -0500)]
ccan_tokenizer: update to be compatible with darray.

11 years agodarray: Renamed array module to darray and made several improvements.
Joey Adams [Sat, 19 Feb 2011 10:36:14 +0000 (05:36 -0500)]
darray: Renamed array module to darray and made several improvements.

 * Removed talloc support.
 * Added a synopsis and rearranged macro definitions.
 * Switched allocation strategy from increments of 64 to powers of 2.
 * Replaced array_for and array_rof with the more useful
   and portable macros array_foreach and array_foreach_reverse.
 * Added typedefs array_* for common types.

11 years agofailtest: detect leaks in children.
Rusty Russell [Tue, 15 Feb 2011 13:02:13 +0000 (23:32 +1030)]
failtest: detect leaks in children.

If we need to clean up the children, they didn't exit cleanly.

This takes a bit more care when writing tests, but found a leak in tdb2.

11 years agofailtest: hook can return FAIL_PROBE
Rusty Russell [Tue, 15 Feb 2011 13:01:29 +0000 (23:31 +1030)]
failtest: hook can return FAIL_PROBE

tdb2 has various places where it recovers from failure (eg. falling
back when it can't open /dev/urandom, or allocation for error
logging).  We want to test those paths, but doing so thoroughly causes
cominatorial explosion.

Add FAIL_PROBE for such cases: in this case it goes only 3 more calls

11 years agofailtest: record close events
Rusty Russell [Tue, 15 Feb 2011 12:59:13 +0000 (23:29 +1030)]
failtest: record close events

We trap them, might as well put them in history.  This also makes tracking
open file descriptors more robust.

11 years agofailtest: call failtest_exit_check even in non-failing parent.
Rusty Russell [Tue, 15 Feb 2011 12:59:28 +0000 (23:29 +1030)]
failtest: call failtest_exit_check even in non-failing parent.

11 years agofailtest: be clearer when child times out.
Rusty Russell [Tue, 15 Feb 2011 12:57:43 +0000 (23:27 +1030)]
failtest: be clearer when child times out.

ie. SIGUSR1 means it timed out.

11 years agofailtest: --debugpath= for really hard-to-find bugs.
Rusty Russell [Tue, 15 Feb 2011 12:57:15 +0000 (23:27 +1030)]
failtest: --debugpath= for really hard-to-find bugs.

If children and parents aren't isolated properly (ie. failtest is
buggy) we really want to run gdb on a failing child.  This hack allows that.

11 years agofailtest: don't insert spurious failures if open would fail anyway.
Rusty Russell [Tue, 15 Feb 2011 12:55:40 +0000 (23:25 +1030)]
failtest: don't insert spurious failures if open would fail anyway.

open fails in fairly normal cases; don't double execution time for this!

11 years agofailtest: don't insist parents and children write the same thing to files.
Rusty Russell [Tue, 15 Feb 2011 12:55:03 +0000 (23:25 +1030)]
failtest: don't insist parents and children write the same thing to files.

We insist they write the same things to pipes, since we can't "undo" them,
but strictly speaking we don't care if they write different things into

Note: it may indicate a bug if they do...

11 years agofailtest: rely on the save/restore of files, don't use write cleanup.
Rusty Russell [Tue, 15 Feb 2011 12:53:59 +0000 (23:23 +1030)]
failtest: rely on the save/restore of files, don't use write cleanup.

11 years agofailtest: save entire file contents.
Rusty Russell [Tue, 15 Feb 2011 12:53:16 +0000 (23:23 +1030)]
failtest: save entire file contents.

The idea of saving files as we do writes doesn't work with mmap: this just
saves the entire contents of all open files before forking child, and
restores them afterwards.

11 years agofailtest: don't use special data structure for storing child writes.
Rusty Russell [Tue, 15 Feb 2011 12:52:17 +0000 (23:22 +1030)]
failtest: don't use special data structure for storing child writes.

Use the same structure we use in the history.

11 years agofailtest: generic cleanup hooks
Rusty Russell [Tue, 15 Feb 2011 12:51:42 +0000 (23:21 +1030)]
failtest: generic cleanup hooks

Each function in the history stores a cleanup function, rather than storing
extra structures.  In particular, we save writes and file offsets using

11 years agofailtest: allow continuing after running a failpath.
Rusty Russell [Tue, 15 Feb 2011 12:49:00 +0000 (23:19 +1030)]
failtest: allow continuing after running a failpath.

Append a "+" if you want to start forking as normal.

11 years agofailtest: --tracepath
Rusty Russell [Tue, 15 Feb 2011 12:48:31 +0000 (23:18 +1030)]
failtest: --tracepath

Useful for showing exactly where we inserted failures, and how long each
one took.

11 years agofailtest: fix history when --failpath used
Rusty Russell [Tue, 15 Feb 2011 12:32:16 +0000 (23:02 +1030)]
failtest: fix history when --failpath used

Correctly mark which calls we failed.

11 years agofailtest: capture pread/pwrite
Rusty Russell [Tue, 15 Feb 2011 12:33:35 +0000 (23:03 +1030)]
failtest: capture pread/pwrite

11 years agofailtest: handle 2-argument open()
Rusty Russell [Tue, 15 Feb 2011 12:33:24 +0000 (23:03 +1030)]
failtest: handle 2-argument open()

11 years agofailtest: fcntl handling
Rusty Russell [Tue, 15 Feb 2011 12:33:06 +0000 (23:03 +1030)]
failtest: fcntl handling

Catch fcntl, particularly fcntl locks.

11 years agoccanlint: print coverage amount when -vv
Rusty Russell [Thu, 17 Feb 2011 23:54:17 +0000 (10:24 +1030)]
ccanlint: print coverage amount when -vv

11 years agoccanlint: fix format error when test output contains %
Rusty Russell [Thu, 17 Feb 2011 23:54:01 +0000 (10:24 +1030)]
ccanlint: fix format error when test output contains %

11 years agonet: reset slen properly in testing.
Rusty Russell [Tue, 22 Feb 2011 04:55:54 +0000 (15:25 +1030)]
net: reset slen properly in testing.

11 years agonet: fix tests on hosts where 'localhost' is v4 _and_ v6
Sam Vilain [Tue, 22 Feb 2011 04:56:36 +0000 (15:26 +1030)]
net: fix tests on hosts where 'localhost' is v4 _and_ v6
If 'localhost' exists in /etc/hosts with a v4 and a v6 address, the hack
which joins two addrinfo entries together is not necessary.  Detect to see
if 'localhost' returned a v6 address, and if so, just return the single
linked list result from getaddrinfo()

(Reworked by Rusty Russell)
Signed-off-by: Sam Vilain <>
11 years agoopt: Add a function to free the internal memory.
Andreas Schlick [Thu, 17 Feb 2011 21:58:44 +0000 (22:58 +0100)]
opt: Add a function to free the internal memory.

11 years agoopt: Correct the separator in _info's example.
Andreas Schlick [Thu, 17 Feb 2011 21:50:07 +0000 (22:50 +0100)]
opt: Correct the separator in _info's example.

11 years agoccanlint: recognise new BSD 3-clause license.
Rusty Russell [Tue, 22 Feb 2011 03:35:51 +0000 (14:05 +1030)]
ccanlint: recognise new BSD 3-clause license.

11 years agolicenses: clarify which BSD license it is.
Rusty Russell [Tue, 22 Feb 2011 03:33:15 +0000 (14:03 +1030)]
licenses: clarify which BSD license it is.

11 years agoMerge branch 'daemon-with-notify' of git:// into daemon...
Rusty Russell [Tue, 22 Feb 2011 02:14:45 +0000 (12:44 +1030)]
Merge branch 'daemon-with-notify' of git:// into daemon-with-notify

11 years agoweb: delete unused tool binaries.
Rusty Russell [Fri, 18 Feb 2011 10:36:59 +0000 (21:06 +1030)]
web: delete unused tool binaries.

11 years agomove daemon-with-notify to daemon_with_notify as dashes aren't allowed in CCAN module...
Stewart Smith [Fri, 11 Feb 2011 01:06:24 +0000 (12:06 +1100)]
move daemon-with-notify to daemon_with_notify as dashes aren't allowed in CCAN module names (and ccanlint segfaults on them)

11 years agofix up daemon-with-notify test
Stewart Smith [Fri, 11 Feb 2011 01:00:25 +0000 (12:00 +1100)]
fix up daemon-with-notify test

11 years agocan't use C comments in C comments - DUH
Stewart Smith [Fri, 11 Feb 2011 00:25:25 +0000 (11:25 +1100)]
can't use C comments in C comments - DUH

11 years agoupdate include to match header name conforming to CCAN standard
Stewart Smith [Fri, 11 Feb 2011 00:23:04 +0000 (11:23 +1100)]
update include to match header name conforming to CCAN standard

11 years agorename source to match CCAN standards
Stewart Smith [Fri, 11 Feb 2011 00:22:25 +0000 (11:22 +1100)]
rename source to match CCAN standards

11 years agoupdate test case copied from daemonize to use some of daemon-with-notify features
Stewart Smith [Fri, 11 Feb 2011 00:17:44 +0000 (11:17 +1100)]
update test case copied from daemonize to use some of daemon-with-notify features

11 years agofix function declaration for daemon_is_ready()
Stewart Smith [Fri, 11 Feb 2011 00:17:08 +0000 (11:17 +1100)]
fix function declaration for daemon_is_ready()

11 years agouse proper include path for daemon.h
Stewart Smith [Fri, 11 Feb 2011 00:13:37 +0000 (11:13 +1100)]
use proper include path for daemon.h

11 years agoadd daemon.h and documentation on functions
Stewart Smith [Fri, 11 Feb 2011 00:12:27 +0000 (11:12 +1100)]
add daemon.h and documentation on functions

11 years agoremove ident headers from daemon-with-notify/daemon.c
Stewart Smith [Fri, 11 Feb 2011 00:03:07 +0000 (11:03 +1100)]
remove ident headers from daemon-with-notify/daemon.c

11 years agoadd basic bit of daemon-with-notify (mostly just from the Drizzle tree)
Stewart Smith [Thu, 10 Feb 2011 23:53:25 +0000 (10:53 +1100)]
add basic bit of daemon-with-notify (mostly just from the Drizzle tree)

11 years agoopt: Silence unsed param warning triggered by -Wextra
Joel Stanley [Mon, 7 Feb 2011 04:06:16 +0000 (14:36 +1030)]
opt: Silence unsed param warning triggered by -Wextra

The type checking function does not use its parameter:

    ccan/opt/opt.h: In function ‘_check_is_entry’:
        ccan/opt/opt.h:328:53: warning: unused parameter ‘e’

Annotate the function using UNUSED from compiler.h.  This commit also
adds compiler.h as a dependency for opt.

11 years agoopt: Fix -Wmissing-field-initializers warning
Joel Stanley [Mon, 7 Feb 2011 04:06:15 +0000 (14:36 +1030)]
opt: Fix -Wmissing-field-initializers warning

OPT_ENDTABLE does not initalise all the elements in stuct opt_table.
When compliling with -Wextra -Wmissing-field-initializers is enabled,
which produces the following warning:

        iviewiir.c:299:9: error: missing field 'cb' initializer
        In file included from iviewiir.c:12:
        ./ccan/opt/opt.h:82:38: note: instantiated from:
        #define OPT_ENDTABLE { NULL, OPT_END }
By changing the definition of OPT_ENDTABLE to initalise all 7 elements
of struct opt_table, the warning is silenced.

11 years agoAdd libccan.a to ignore list.
Brad Hards [Tue, 1 Feb 2011 01:11:30 +0000 (12:11 +1100)]
Add libccan.a to ignore list.

12 years agonet: remove noerr dependency.
Rusty Russell [Sun, 30 Jan 2011 08:24:28 +0000 (18:54 +1030)]
net: remove noerr dependency.

It's cool, but making it standalone is slightly simpler and means license is
pure MIT.

12 years agonet: fix latent bug in _info example.
Rusty Russell [Sat, 29 Jan 2011 07:42:20 +0000 (18:12 +1030)]
net: fix latent bug in _info example.

Ben Hutchings points out that struct sockaddr isn't large enough to hold
a struct sockaddr_in6.  Our example works because we only access the family
field, but anyone extending it might be surprised; use a union instead.

12 years agoccanlint: fix SEGV when example has format string.
Rusty Russell [Fri, 28 Jan 2011 06:41:06 +0000 (17:11 +1030)]
ccanlint: fix SEGV when example has format string.

12 years agonet: new module to help IPv4/IPv6 transition.
Rusty Russell [Fri, 28 Jan 2011 06:40:23 +0000 (17:10 +1030)]
net: new module to help IPv4/IPv6 transition.

12 years agoccanlint: protect against the function element in the doc section being null
Brad Hards [Wed, 19 Jan 2011 06:03:32 +0000 (17:03 +1100)]
ccanlint: protect against the function element in the doc section being null

This can happen if the documentation doesn't have a properly formatted summary line,
and it causes the examples_relevant test to segfault.

12 years agoccanlint: always print \n at end of error message.
Rusty Russell [Sat, 22 Jan 2011 02:02:54 +0000 (12:32 +1030)]
ccanlint: always print \n at end of error message.

Brad Hards fixed a two places where score->error was not \n-terminated,
and then I found a few more, so make it automatic.

12 years agoccanlint: don't collect results from test children
Rusty Russell [Thu, 20 Jan 2011 01:01:11 +0000 (11:31 +1030)]
ccanlint: don't collect results from test children

This confuses the output, and makes us sometimes see spurious
failure.  At least we will still catch valgrind errors in
children of failtest, thanks to --error-exitcode=101.

12 years agoopt: correct description, and neaten main header order.
Rusty Russell [Tue, 18 Jan 2011 07:21:51 +0000 (17:51 +1030)]
opt: correct description, and neaten main header order.

Reordering header makes it more readable, and we don't rely on
getopt_long any more.

12 years agoccanlint: fix _info option handling
Rusty Russell [Tue, 18 Jan 2011 01:47:17 +0000 (12:17 +1030)]
ccanlint: fix _info option handling

Two places were using a bogus ccanlint struct: the side-effect was
that valgrind options didn't work, nor did license fixups.

Make REGISTER_TEST do the extern declaration, and remove the bogus

12 years agostrsplit: remove nump argument
Rusty Russell [Tue, 18 Jan 2011 00:44:46 +0000 (11:14 +1030)]
strsplit: remove nump argument

You can use talloc_array_length() to get the length of a tallocated array.

12 years agotalloc: talloc_array_length()
Rusty Russell [Tue, 18 Jan 2011 00:36:23 +0000 (11:06 +1030)]
talloc: talloc_array_length()

I originally called this talloc_length(), but SAMBA upstream uses

12 years agoccanlint: -k all
Rusty Russell [Sun, 9 Jan 2011 02:50:14 +0000 (13:20 +1030)]
ccanlint: -k all

Use this to preserve the entire working directory.

12 years agoccanlint: -k should not pollute module directory.
Rusty Russell [Sun, 9 Jan 2011 02:49:15 +0000 (13:19 +1030)]
ccanlint: -k should not pollute module directory.

It leads to numerous problems, such as the next ccanlint getting confused
trying to compile examples, and "-k examples_compile -k examples_exist"
giving bogus errors.

So instead we leave the temporary dir lying around and delete
individual files which aren't marked "keep".

12 years agofailtest: free up everything on exit.
Rusty Russell [Tue, 18 Jan 2011 00:35:37 +0000 (11:05 +1030)]
failtest: free up everything on exit.

Otherwise valgrind will report that tests leak memory.

12 years agofailtest: failtest_restore.h as an antidote to function overload.
Rusty Russell [Tue, 18 Jan 2011 00:38:34 +0000 (11:08 +1030)]
failtest: failtest_restore.h as an antidote to function overload.

This makes some cases simpler, where you no longer want malloc etc.
to fail.

12 years agowwviaudio: spelling fix
Brad Hards [Sun, 16 Jan 2011 06:50:51 +0000 (17:50 +1100)]
wwviaudio: spelling fix

12 years agotdb2: spelling fix
Brad Hards [Sun, 16 Jan 2011 06:50:24 +0000 (17:50 +1100)]
tdb2: spelling fix

12 years agotdb: spelling fixes
Brad Hards [Sun, 16 Jan 2011 06:50:03 +0000 (17:50 +1100)]
tdb: spelling fixes

12 years agotap: spelling fix
Brad Hards [Sun, 16 Jan 2011 06:49:20 +0000 (17:49 +1100)]
tap: spelling fix

12 years agotalloc: spelling fix.
Brad Hards [Sun, 16 Jan 2011 06:48:53 +0000 (17:48 +1100)]
talloc: spelling fix.

12 years agorbtree: spelling fixes
Brad Hards [Sun, 16 Jan 2011 06:48:20 +0000 (17:48 +1100)]
rbtree: spelling fixes

12 years agoopt: spelling fixes.
Brad Hards [Sun, 16 Jan 2011 06:22:39 +0000 (17:22 +1100)]
opt: spelling fixes.

12 years agonfs: spelling fixes.
Brad Hards [Sun, 16 Jan 2011 06:22:14 +0000 (17:22 +1100)]
nfs: spelling fixes.

12 years agolist: spelling fixes
Brad Hards [Sun, 16 Jan 2011 06:21:39 +0000 (17:21 +1100)]
list: spelling fixes

12 years agoiscsi: spelling fixes.
Brad Hards [Sun, 16 Jan 2011 06:21:12 +0000 (17:21 +1100)]
iscsi: spelling fixes.

12 years agohash: spelling fix
Brad Hards [Sun, 16 Jan 2011 06:19:51 +0000 (17:19 +1100)]
hash: spelling fix

12 years agobtree: spelling fix
Brad Hards [Sun, 16 Jan 2011 06:19:12 +0000 (17:19 +1100)]
btree: spelling fix

12 years agociniparser: spelling fixes
Brad Hards [Sun, 16 Jan 2011 06:17:36 +0000 (17:17 +1100)]
ciniparser: spelling fixes

12 years agojunkcode: spelling fixes.
Brad Hards [Sun, 16 Jan 2011 06:16:46 +0000 (17:16 +1100)]
junkcode: spelling fixes.

12 years agoarray: spelling fixes.
Brad Hards [Sun, 16 Jan 2011 06:15:32 +0000 (17:15 +1100)]
array: spelling fixes.

12 years agostr: change example to match function being explained.
Brad Hards [Sun, 16 Jan 2011 05:22:46 +0000 (16:22 +1100)]
str: change example to match function being explained.

Looks like the example was copy-n-pasted from the previous entry.

12 years agoccanlint: check examples actually mention thing they are demonstrating.
Rusty Russell [Mon, 17 Jan 2011 05:50:15 +0000 (16:20 +1030)]
ccanlint: check examples actually mention thing they are demonstrating.

Brad suggested this after finding one such cut & paste in str:

rusty@vivaldi:~/devel/cvs/ccan/ccan/str$ ../../tools/ccanlint/ccanlint
Example: sections demonstrate appropriate function (examples_relevant): FAIL
/home/rusty/devel/cvs/ccan/ccan/str/str.h:64:Example for strcount doesn't mention it
Total score: 37/38

12 years agoccanlint: fix trailing / in -d.
Rusty Russell [Mon, 17 Jan 2011 05:49:13 +0000 (16:19 +1030)]
ccanlint: fix trailing / in -d.

$ tools/ccanlint/ccanlint -d ccan/talloc/
Module's source code has no trailing whitespace (no_trailing_whitespace): FAIL
: Total score: 0/1

$ tools/ccanlint/ccanlint -d ccan/talloc/
Module's source code has no trailing whitespace (no_trailing_whitespace): FAIL
talloc: Total score: 0/1

12 years agoccanlint: score_file_error() takes printf-format
Rusty Russell [Mon, 17 Jan 2011 05:47:49 +0000 (16:17 +1030)]
ccanlint: score_file_error() takes printf-format

We simply build up the error string in score_file_error; a bit different
but simpler than current behaviour.  We keep around struct file_error
because some tests need it.

12 years agoccanlint: fix score for info_summary_single_line
Rusty Russell [Mon, 17 Jan 2011 05:34:42 +0000 (16:04 +1030)]
ccanlint: fix score for info_summary_single_line

My refactoring introduced a bug: we need to set score=1 for the success case.

12 years agociniparser: Separate summary line and description text for metadata
Brad Hards [Mon, 17 Jan 2011 03:02:36 +0000 (13:32 +1030)]
ciniparser: Separate summary line and description text for metadata

12 years agoblock_pool: Change metadata layout so initial description is all on one line.
Brad Hards [Mon, 17 Jan 2011 03:02:36 +0000 (13:32 +1030)]
block_pool: Change metadata layout so initial description is all on one line.

With the original layout, we got:
An efficient allocator for blocks that don't need to be
resized or freed.

12 years agoccanlint: neaten info_summary_single_line with new doc_section info.
Rusty Russell [Mon, 17 Jan 2011 03:52:29 +0000 (14:22 +1030)]
ccanlint: neaten info_summary_single_line with new doc_section info.

12 years agoccanlint: keep mapping back to original source line for doc_extract
Rusty Russell [Mon, 17 Jan 2011 03:44:43 +0000 (14:14 +1030)]
ccanlint: keep mapping back to original source line for doc_extract

Makes reporting of documentation easier.

12 years agoccanlint: add test case for metadata summary line on a single separate line.
Brad Hards [Mon, 17 Jan 2011 03:02:36 +0000 (13:32 +1030)]
ccanlint: add test case for metadata summary line on a single separate line.

12 years agohtable: fix type of cmpfn in htable_type
Rusty Russell [Thu, 13 Jan 2011 08:55:01 +0000 (19:25 +1030)]
htable: fix type of cmpfn in htable_type

It in fact takes an object and a key to compare, not two keys.

The test case had the key as first element of the object, so it worked,
but ccanlint lost track of module dependencies due to this bug, and thus
would build submodules multiple times.

12 years agorbtree: fix allocation failre paths.
Rusty Russell [Mon, 10 Jan 2011 05:55:22 +0000 (16:25 +1030)]
rbtree: fix allocation failre paths.

12 years agorbtree: don't use temporary context to destroy rbtree
Rusty Russell [Mon, 10 Jan 2011 05:17:24 +0000 (15:47 +1030)]
rbtree: don't use temporary context to destroy rbtree

It leads to a memory leak if the allocation fails (as we reparent onto NULL).
Also, the extra allocation in the failure path increases test time for
failtest (under valgrind) by a factor of 2.

12 years agorbtree: use failtest to check handling of allocation failures.
Rusty Russell [Mon, 10 Jan 2011 05:53:46 +0000 (16:23 +1030)]
rbtree: use failtest to check handling of allocation failures.

Unfortunately this means we have to reduce run-many from 1000 nodes to 100
(as forking under valgrind is really slow: test takes about 2 minutes with
100 nodes).

12 years agorbtree: fix memory leak in tests
Rusty Russell [Mon, 10 Jan 2011 05:51:24 +0000 (16:21 +1030)]
rbtree: fix memory leak in tests

The data is not made a child of the tree: the nodes are made children of the
data.  So we must explicitly free the data objects.

12 years agorbtree: vary insert and delete orders in test
Rusty Russell [Mon, 10 Jan 2011 05:55:48 +0000 (16:25 +1030)]
rbtree: vary insert and delete orders in test

This covers more code than simply doing an ordered delete/insert.

12 years agotalloc: allow replacement allocator
Rusty Russell [Mon, 10 Jan 2011 03:36:40 +0000 (14:06 +1030)]
talloc: allow replacement allocator

This allows us to both allocators which handle failure themselves, and
allocators which insert failures.

12 years agotalloc: fixed a use after free error
Rusty Russell [Mon, 10 Jan 2011 05:32:03 +0000 (16:02 +1030)]
talloc: fixed a use after free error

(Import from SAMBA commit 6f51a1f45bf4de062cce7a562477e8140630a53d):

this is the minimal fix for the problem Rusty found. I previously
thought that the best fix would be to change tc->parent to be valid
for all pointers, but that is expensive for realloc with large numbers
of child pointers, which is much more commmon than I expected it to