wiredtiger/wiredtiger — pull request #563 by michaelcahill (2013-05-31 05:08:37+00:00)
Title: Add a new `__wt_realloc_def` macro that simplifies space management

Our interface to `realloc` is somewhat complex, requiring the already-allocated size to be tracked, along with a calculation of the new size in bytes.

This branch adds a `__wt_realloc_def` macro, matching `__wt_calloc_def`, that uses the type of the pointer to determine the element size, so that only a number of elements is required. It is a no-op if enough space is already allocated, and includes a common policy for growing the array without excessive reallocation.

This simplifies many existing uses of `__wt_realloc` and avoids several classes of bugs, including using the wrong element type in `sizeof` calculations.