The following commit has been merged in the master branch:
commit f1891335a4686a8859e4f77be1cd5d8061e0b56e
Author: Guillem Jover <[email protected]>
Date:   Fri Feb 4 19:40:33 2011 +0100

    dpkg: Remove useless cidirbuf variable in process_archive()
    
    Remove cidirbuf and make cidir a static function scope variable.

diff --git a/src/processarc.c b/src/processarc.c
index a62ced6..00b9504 100644
--- a/src/processarc.c
+++ b/src/processarc.c
@@ -172,7 +172,7 @@ void process_archive(const char *filename) {
    * we unwind the stack before processing the cleanup list, and these
    * variables had better still exist ... */
   static int p1[2];
-  static char *cidirbuf = NULL;
+  static char *cidir = NULL;
   static struct fileinlist *newconffiles, *newfileslist;
   static enum pkgstatus oldversionstatus;
   static struct varbuf infofnvb, fnvb, depprobwhy;
@@ -182,7 +182,7 @@ void process_archive(const char *filename) {
   pid_t pid;
   struct pkgiterator *it;
   struct pkginfo *pkg, *otherpkg, *divpkg;
-  char *cidir, *cidirrest, *p;
+  char *cidirrest, *p;
   char conffilenamebuf[MAXCONFFILENAME];
   char *psize;
   const char *pfilename, *newinfofilename;
@@ -220,13 +220,13 @@ void process_archive(const char *filename) {
   if (f_noact) {
     char *tmpdir;
 
-    if (!cidirbuf)
-      free(cidirbuf);
     tmpdir = mkdtemp(path_make_temp_template("dpkg"));
     if (!tmpdir)
       ohshite(_("unable to create temporary directory"));
 
-    cidir = cidirbuf = m_malloc(strlen(tmpdir) + MAXCONTROLFILENAME + 10);
+    if (!cidir)
+      free(cidir);
+    cidir = m_malloc(strlen(tmpdir) + MAXCONTROLFILENAME + 10);
     strcpy(cidir, tmpdir);
     strcat(cidir,"/");
 
@@ -236,10 +236,9 @@ void process_archive(const char *filename) {
   } else {
     /* We want it to be on the same filesystem so that we can
      * use rename(2) to install the postinst &c. */
-    if (!cidirbuf)
-      cidirbuf = m_malloc(strlen(admindir) + sizeof(CONTROLDIRTMP) +
-                          MAXCONTROLFILENAME + 10);
-    cidir= cidirbuf;
+    if (!cidir)
+      cidir = m_malloc(strlen(admindir) + sizeof(CONTROLDIRTMP) +
+                       MAXCONTROLFILENAME + 10);
     strcpy(cidir,admindir);
     strcat(cidir, "/" CONTROLDIRTMP);
 

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to