mongodb/mongo-c-driver — pull request #130 by gerald-lindsly (2013-04-14 17:49:26+00:00)
Title: Address initialization problems.  Some minor fixes as I went.

I have attempted to address the initialization problems in an efficient manner.

_bson_zero() was renamed to bson_init_zero() and made public (so mongo.c can call it); otherwise, it is a convenience function for the paranoid. ;) I moved the stack to the end of the bson struct so bson_init_zero() can clear everything but that easily.

bson_find_one() was fixed so that it calls bson_init_zero() if it doesn't otherwise return a bson. This solved a lot of problems as use of this function is widespread.

Unnecessary initializers have been dropped.

mongo_get_error_helper() now also calls bson_init_zero(). After calling those functions that depend on it { mongo_create_index(), mongo_create_simple_index(),
mongo_cmd_get_last_error() and mongo_cmd_get_prev_error() },
one should call bson_has_data() to see if the function really returned an error bson.

Small syntax and logic fixes as I went. Some formatting in gridfs.c I really can't read the stuff with a bunch of extra braces thrown in. Deeper indenting would help too.

This compiles, but I have not tested it. Can someone help me with this part? My drivers are a bit out of date with mongo-c-driver as is. Next project I suppose is to these catch up.