Add a precautionary pair of initialisations to placate optimisers,

and asserts to check that the preinitialised values are never
actually used.

[originally from svn r8745]
This commit is contained in:
Simon Tatham
2009-11-10 19:11:03 +00:00
parent ddbe9abe8a
commit 9c95ea2619

View File

@ -1182,6 +1182,7 @@ static node234 *split234_internal(tree234 *t, int index) {
/* /*
* Search down the tree to find the split point. * Search down the tree to find the split point.
*/ */
halves[0] = halves[1] = NULL;
lparent = rparent = NULL; lparent = rparent = NULL;
pki = -1; pki = -1;
while (n) { while (n) {
@ -1273,6 +1274,8 @@ static node234 *split234_internal(tree234 *t, int index) {
*/ */
LOG((" fell off bottom, lroot is %p, rroot is %p\n", LOG((" fell off bottom, lroot is %p, rroot is %p\n",
halves[0], halves[1])); halves[0], halves[1]));
assert(halves[0] != NULL);
assert(halves[1] != NULL);
lparent->counts[pki] = rparent->counts[0] = 0; lparent->counts[pki] = rparent->counts[0] = 0;
lparent->kids[pki] = rparent->kids[0] = NULL; lparent->kids[pki] = rparent->kids[0] = NULL;
@ -1475,6 +1478,7 @@ tree234 *copytree234(tree234 *t, copyfn234 copyfn, void *copyfnstate) {
* if not.) * if not.)
*/ */
#include <string.h>
#include <stdarg.h> #include <stdarg.h>
#define srealloc realloc #define srealloc realloc