vacuum: introduce a helper variable in add_record_to_vacuum_fetch_list() to reduce...
authorMichael Adam <obnox@samba.org>
Fri, 16 Dec 2011 09:43:06 +0000 (10:43 +0100)
committerMichael Adam <obnox@samba.org>
Fri, 23 Dec 2011 16:39:06 +0000 (17:39 +0100)
server/ctdb_vacuum.c

index 6e090ff24630bf829cd15caff2841a6d788e035c..586c2e54cd828b404b32690f55e08ca38c0b3732 100644 (file)
@@ -173,27 +173,30 @@ static int add_record_to_vacuum_fetch_list(struct vacuum_data *vdata,
        struct ctdb_rec_data *rec;
        uint32_t lmaster;
        size_t old_size;
+       struct ctdb_marshall_buffer *vfl;
 
        lmaster = ctdb_lmaster(ctdb, &key);
 
-       rec = ctdb_marshall_record(vdata->list[lmaster], ctdb->pnn, key, NULL, tdb_null);
+       vfl = vdata->list[lmaster];
+
+       rec = ctdb_marshall_record(vfl, ctdb->pnn, key, NULL, tdb_null);
        if (rec == NULL) {
                DEBUG(DEBUG_ERR,(__location__ " Out of memory\n"));
                vdata->traverse_error = true;
                return -1;
        }
 
-       old_size = talloc_get_size(vdata->list[lmaster]);
-       vdata->list[lmaster] = talloc_realloc_size(NULL, vdata->list[lmaster],
-                                                  old_size + rec->length);
-       if (vdata->list[lmaster] == NULL) {
+       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;
 
-       vdata->list[lmaster]->count++;
-       memcpy(old_size+(uint8_t *)vdata->list[lmaster], rec, rec->length);
+       vfl->count++;
+       memcpy(old_size+(uint8_t *)vfl, rec, rec->length);
        talloc_free(rec);
 
        vdata->total++;