logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

bson_valgrind - Use Valgrind to Check For BSON Data Leaks

Author

       MongoDB, Inc

Name

       bson_valgrind - Use Valgrind to Check For BSON Data Leaks

       A  stack-allocated  bson_t contains a small internal buffer; it only heap-allocates additional storage if
       necessary, depending on its data size. Therefore if you forget to call bson_destroy on a  stack-allocated
       bson_t, it might or might not cause a leak that can be detected by valgrind during testing.

       To catch all potential BSON data leaks in your code, configure the BSON_MEMCHECK flag:

          cmake -DCMAKE_C_FLAGS="-DBSON_MEMCHECK -g" .

       With this flag set, every bson_t mallocs at least one byte. Run your program's unittests with valgrind to
       verify all bson_t structs are destroyed.

       Set the environment variable MONGOC_TEST_VALGRIND to on to skip timing-dependent tests known to fail with
       valgrind.

See Also