X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fwrite_mongodb.c;h=63d3716baf161d303fb5b86f8ea13cde9ddf9526;hb=7f9c8e704314392b556c27e4034fd910c25b6377;hp=3cdc3d1db873847924493a57b0357650bcaa7610;hpb=307c875e5a78a2729fbbe1a588d232e9a129d75a;p=collectd.git diff --git a/src/write_mongodb.c b/src/write_mongodb.c index 3cdc3d1d..63d3716b 100644 --- a/src/write_mongodb.c +++ b/src/write_mongodb.c @@ -78,7 +78,7 @@ static bson_t *wm_create_bson(const data_set_t *ds, /* {{{ */ rates = uc_get_rate(ds, vl); if (rates == NULL) { ERROR("write_mongodb plugin: uc_get_rate() failed."); - bson_free(ret); + bson_destroy(ret); return NULL; } } else { @@ -111,7 +111,7 @@ static bson_t *wm_create_bson(const data_set_t *ds, /* {{{ */ else { ERROR("write_mongodb plugin: Unknown ds_type %d for index %d", ds->ds[i].type, i); - bson_free(ret); + bson_destroy(ret); return NULL; } } @@ -144,8 +144,9 @@ static bson_t *wm_create_bson(const data_set_t *ds, /* {{{ */ size_t error_location; if (!bson_validate(ret, BSON_VALIDATE_UTF8, &error_location)) { ERROR("write_mongodb plugin: Error in generated BSON document " - "at byte %zu", error_location); - bson_free(ret); + "at byte %zu", + error_location); + bson_destroy(ret); return NULL; } @@ -249,7 +250,7 @@ static int wm_write(const data_set_t *ds, /* {{{ */ if (wm_initialize(node) < 0) { ERROR("write_mongodb plugin: error making connection to server"); pthread_mutex_unlock(&node->lock); - bson_free(bson_record); + bson_destroy(bson_record); return -1; } @@ -263,7 +264,7 @@ static int wm_write(const data_set_t *ds, /* {{{ */ node->client = NULL; node->connected = 0; pthread_mutex_unlock(&node->lock); - bson_free(bson_record); + bson_destroy(bson_record); return -1; } @@ -278,7 +279,7 @@ static int wm_write(const data_set_t *ds, /* {{{ */ node->client = NULL; node->connected = 0; pthread_mutex_unlock(&node->lock); - bson_free(bson_record); + bson_destroy(bson_record); mongoc_collection_destroy(collection); return -1; } @@ -288,7 +289,7 @@ static int wm_write(const data_set_t *ds, /* {{{ */ pthread_mutex_unlock(&node->lock); - bson_free(bson_record); + bson_destroy(bson_record); return 0; } /* }}} int wm_write */ @@ -377,10 +378,11 @@ static int wm_config_node(oconfig_item_t *ci) /* {{{ */ ssnprintf(cb_name, sizeof(cb_name), "write_mongodb/%s", node->name); - status = plugin_register_write( - cb_name, wm_write, &(user_data_t){ - .data = node, .free_func = wm_config_free, - }); + status = + plugin_register_write(cb_name, wm_write, + &(user_data_t){ + .data = node, .free_func = wm_config_free, + }); INFO("write_mongodb plugin: registered write plugin %s %d", cb_name, status); }