summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0accb68)
raw | patch | inline | side by side (parent: 0accb68)
author | Florian Forster <octo@collectd.org> | |
Mon, 9 Mar 2015 09:59:38 +0000 (10:59 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Mon, 9 Mar 2015 10:04:20 +0000 (11:04 +0100) |
According to the mongo-c-driver 0.8.1 documentation, each call to
bson_alloc() needs to be matched by a call to bson_dealloc() and each
call to bson_init() needs to be matched by a call to bson_destroy().
Additionally, this patch adds macros for mongo-c-driver < 0.8.0 to map
the new bson_alloc() and bson_deallow() names to the old bson_create()
and bson_dispose() symbol names.
Tested with mongo-c-driver 0.8.1 and 0.7.1.
Fixes: #331, #956
bson_alloc() needs to be matched by a call to bson_dealloc() and each
call to bson_init() needs to be matched by a call to bson_destroy().
Additionally, this patch adds macros for mongo-c-driver < 0.8.0 to map
the new bson_alloc() and bson_deallow() names to the old bson_create()
and bson_dispose() symbol names.
Tested with mongo-c-driver 0.8.1 and 0.7.1.
Fixes: #331, #956
src/write_mongodb.c | patch | blob | history |
diff --git a/src/write_mongodb.c b/src/write_mongodb.c
index a12bdd01728569dbe33e1d1e2e349a5e633996b1..24151ceb720a3a29a055a0a24e7cdc6993661d45 100644 (file)
--- a/src/write_mongodb.c
+++ b/src/write_mongodb.c
#endif
#include <mongo.h>
+#if (MONGO_MAJOR == 0) && (MONGO_MINOR < 8)
+# define bson_alloc() bson_create()
+# define bson_dealloc(b) bson_dispose(b)
+#endif
+
struct wm_node_s
{
char name[DATA_MAX_NAME_LEN];
gauge_t *rates;
int i;
- ret = bson_create ();
+ ret = bson_alloc (); /* matched by bson_dealloc() */
if (ret == NULL)
{
ERROR ("write_mongodb plugin: bson_create failed.");
rates = NULL;
}
- bson_init (ret);
+ bson_init (ret); /* matched by bson_destroy() */
bson_append_date (ret, "time", (bson_date_t) CDTIME_T_TO_MS (vl->time));
bson_append_string (ret, "host", vl->host);
bson_append_string (ret, "plugin", vl->plugin);
pthread_mutex_unlock (&node->lock);
/* free our resource as not to leak memory */
- bson_destroy (bson_record);
+ bson_destroy (bson_record); /* matches bson_init() */
+ bson_dealloc (bson_record); /* matches bson_alloc() */
return (0);
} /* }}} int wm_write */