]> git.saurik.com Git - apt.git/blobdiff - methods/rred.cc
follow the recommendation of cppcheck to make some method methods (scnr)
[apt.git] / methods / rred.cc
index 80cd14986ea4f4d34317a5732dd1f6992786f228..6c55880ca1726c782bd1f939c50952a7f083c0ba 100644 (file)
@@ -51,7 +51,7 @@ protected:
        virtual bool Fetch(FetchItem *Itm);
 
 public:
-       RredMethod() : pkgAcqMethod("1.1",SingleInstance | SendConfig) {};
+       RredMethod() : pkgAcqMethod("1.1",SingleInstance | SendConfig), Debug(false) {};
 };
                                                                                /*}}}*/
 /** \brief applyFile - in reverse order with a tail recursion                  {{{
@@ -239,7 +239,9 @@ RredMethod::State RredMethod::patchFile(FileFd &Patch, FileFd &From,                /*{{{*/
    return result;
 }
                                                                                /*}}}*/
-struct EdCommand {                                                             /*{{{*/
+/* struct EdCommand                                                            {{{*/
+#ifdef _POSIX_MAPPED_FILES
+struct EdCommand {
   size_t data_start;
   size_t data_end;
   size_t data_lines;
@@ -248,6 +250,7 @@ struct EdCommand {                                                          /*{{{*/
   char type;
 };
 #define IOV_COUNT 1024 /* Don't really want IOV_MAX since it can be arbitrarily large */
+#endif
                                                                                /*}}}*/
 RredMethod::State RredMethod::patchMMap(FileFd &Patch, FileFd &From,           /*{{{*/
                                        FileFd &out_file, Hashes *hash) const {
@@ -255,9 +258,14 @@ RredMethod::State RredMethod::patchMMap(FileFd &Patch, FileFd &From,               /*{{{*/
        MMap ed_cmds(MMap::ReadOnly);
        if (Patch.gzFd() != NULL) {
                unsigned long mapSize = Patch.Size();
-               DynamicMMap dyn(0, mapSize, 0);
-               gzread(Patch.gzFd(), dyn.Data(), mapSize);
-               ed_cmds = dyn;
+               DynamicMMap* dyn = new DynamicMMap(0, mapSize, 0);
+               if (dyn->validData() == false) {
+                       delete dyn;
+                       return MMAP_FAILED;
+               }
+               dyn->AddSize(mapSize);
+               gzread(Patch.gzFd(), dyn->Data(), mapSize);
+               ed_cmds = *dyn;
        } else
                ed_cmds = MMap(Patch, MMap::ReadOnly);