diff options
author | Amitay Isaacs <amitay@gmail.com> | 2014-05-06 18:39:25 +1000 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2014-07-23 07:18:11 +0200 |
commit | 6edc4f23e9094860ad5cc6b93ce66169dd99047a (patch) | |
tree | 5f829267ac5fd911f2bf2a93d8bef4e378c7085b /ctdb | |
parent | 42ba7a0a400c970dd534e92d2effa3ed385f8d6d (diff) | |
download | samba-6edc4f23e9094860ad5cc6b93ce66169dd99047a.tar.gz |
ctdb-vacuum: Use ctdb_marshall_add to add a record to marshall buffer
This avoids duplicate code and extra talloc in ctdb_marshall_record.
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'ctdb')
-rw-r--r-- | ctdb/server/ctdb_vacuum.c | 38 |
1 files changed, 10 insertions, 28 deletions
diff --git a/ctdb/server/ctdb_vacuum.c b/ctdb/server/ctdb_vacuum.c index 491103f8c34..fe59a83fcfa 100644 --- a/ctdb/server/ctdb_vacuum.c +++ b/ctdb/server/ctdb_vacuum.c @@ -181,35 +181,23 @@ static int add_record_to_vacuum_fetch_list(struct vacuum_data *vdata, TDB_DATA key) { struct ctdb_context *ctdb = vdata->ctdb; - struct ctdb_rec_data *rec; uint32_t lmaster; - size_t old_size; struct ctdb_marshall_buffer *vfl; lmaster = ctdb_lmaster(ctdb, &key); vfl = vdata->vacuum_fetch_list[lmaster]; - rec = ctdb_marshall_record(vfl, ctdb->pnn, key, NULL, tdb_null); - if (rec == NULL) { + vfl = ctdb_marshall_add(ctdb, vfl, vfl->db_id, ctdb->pnn, + key, NULL, tdb_null); + if (vfl == NULL) { DEBUG(DEBUG_ERR,(__location__ " Out of memory\n")); vdata->traverse_error = true; return -1; } - old_size = talloc_get_size(vfl); - vfl = talloc_realloc_size(NULL, vfl, old_size + rec->length); - if (vfl == NULL) { - DEBUG(DEBUG_ERR,(__location__ " Failed to expand\n")); - vdata->traverse_error = true; - return -1; - } vdata->vacuum_fetch_list[lmaster] = vfl; - vfl->count++; - memcpy(old_size+(uint8_t *)vfl, rec, rec->length); - talloc_free(rec); - return 0; } @@ -294,23 +282,17 @@ static int delete_marshall_traverse(void *param, void *data) { struct delete_record_data *dd = talloc_get_type(data, struct delete_record_data); struct delete_records_list *recs = talloc_get_type(param, struct delete_records_list); - struct ctdb_rec_data *rec; - size_t old_size; + struct ctdb_marshall_buffer *m; - rec = ctdb_marshall_record(dd, recs->records->db_id, dd->key, &dd->hdr, tdb_null); - if (rec == NULL) { + m = ctdb_marshall_add(recs, recs->records, recs->records->db_id, + recs->records->db_id, + dd->key, &dd->hdr, tdb_null); + if (m == NULL) { DEBUG(DEBUG_ERR, (__location__ " failed to marshall record\n")); - return 0; - } - - old_size = talloc_get_size(recs->records); - recs->records = talloc_realloc_size(recs, recs->records, old_size + rec->length); - if (recs->records == NULL) { - DEBUG(DEBUG_ERR,(__location__ " Failed to expand\n")); return -1; } - recs->records->count++; - memcpy(old_size+(uint8_t *)(recs->records), rec, rec->length); + + recs->records = m; return 0; } |