Просмотр исходного кода

dpkg-deb: Refactor file info structure creation into a new function

Guillem Jover лет назад: 17
Родитель
Сommit
52557dc633
1 измененных файлов с 14 добавлено и 3 удалено
  1. 14 3
      dpkg-deb/build.c

+ 14 - 3
dpkg-deb/build.c

@@ -103,6 +103,18 @@ static void checkversion(const char *vstring, const char *valuename, int *errs)
   (*errs)++;
 }
 
+static struct file_info *
+file_info_new(const char *filename)
+{
+  struct file_info *fi;
+
+  fi = m_malloc(sizeof(*fi));
+  fi->fn = m_strdup(filename);
+  fi->next = NULL;
+
+  return fi;
+}
+
 /*
  * Read the next filename from a filedescriptor and create a file_info struct
  * for it. If there is nothing to read return NULL.
@@ -148,10 +160,9 @@ getfi(const char *root, int fd)
       ohshit(_("file name '%.50s...' is too long"), fn + rl + 1);
   }
 
-  fi = m_malloc(sizeof(*fi));
+  fi = file_info_new(fn + rl + 1);
   lstat(fn, &(fi->st));
-  fi->fn = m_strdup(fn + rl + 1);
-  fi->next=NULL;
+
   return fi;
 }