X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=main.cc;h=742af6c5f7e169bbce5398f231119299fde67fef;hb=3a2c12889e60ed903e7c3c5d99baa04ed23f3221;hp=f06f0188806693691dc01fe1592a2822de705032;hpb=01776f600be2a246400d1e6e135b77f8e549c833;p=cumulus.git diff --git a/main.cc b/main.cc index f06f018..742af6c 100644 --- a/main.cc +++ b/main.cc @@ -46,6 +46,7 @@ #include #include +#include "cumulus.h" #include "exclude.h" #include "hash.h" #include "localdb.h" @@ -226,7 +227,7 @@ int64_t dumpfile(int fd, dictionary &file_info, const string &path, /* If the file is new or changed, we must read in the contents a block at a * time. */ if (!cached) { - Hash *hash = Hash::New(); + scoped_ptr file_hash(Hash::New()); Subfile subfile(db); subfile.load_old_blocks(old_blocks); @@ -240,7 +241,7 @@ int64_t dumpfile(int fd, dictionary &file_info, const string &path, break; } - hash->update(block_buf, bytes); + file_hash->update(block_buf, bytes); // Sparse file processing: if we read a block of all zeroes, encode // that explicitly. @@ -257,10 +258,9 @@ int64_t dumpfile(int fd, dictionary &file_info, const string &path, double block_age = 0.0; ObjectReference ref; - Hash *hash = Hash::New(); - hash->update(block_buf, bytes); - string block_csum = hash->digest_str(); - delete hash; + scoped_ptr block_hash(Hash::New()); + block_hash->update(block_buf, bytes); + string block_csum = block_hash->digest_str(); if (all_zero) { ref = ObjectReference(ObjectReference::REF_ZERO); @@ -323,8 +323,7 @@ int64_t dumpfile(int fd, dictionary &file_info, const string &path, status = "old"; } - file_info["checksum"] = hash->digest_str(); - delete hash; + file_info["checksum"] = file_hash->digest_str(); } // Sanity check: if we are rebuilding the statcache, but the file looks @@ -851,8 +850,8 @@ int main(int argc, char *argv[]) dbmeta_filename += backup_scheme + "-"; dbmeta_filename += timestamp + ".meta" + filter_extension; RemoteFile *dbmeta_file = remote->alloc_file(dbmeta_filename, "meta"); - FileFilter *dbmeta_filter = FileFilter::New(dbmeta_file->get_fd(), - filter_program); + scoped_ptr dbmeta_filter(FileFilter::New(dbmeta_file->get_fd(), + filter_program)); if (dbmeta_filter == NULL) { fprintf(stderr, "Unable to open descriptor output file: %m\n"); return 1; @@ -900,8 +899,8 @@ int main(int argc, char *argv[]) RemoteFile *descriptor_file = remote->alloc_file(desc_filename, "snapshots"); - FileFilter *descriptor_filter = FileFilter::New(descriptor_file->get_fd(), - signature_filter.c_str()); + scoped_ptr descriptor_filter( + FileFilter::New(descriptor_file->get_fd(), signature_filter.c_str())); if (descriptor_filter == NULL) { fprintf(stderr, "Unable to open descriptor output file: %m\n"); return 1;