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

libdpkg: Use sizeof_array instead of ad-hoc calculation

Guillem Jover лет назад: 18
Родитель
Сommit
1ccfc48ad3
2 измененных файлов с 7 добавлено и 1 удалено
  1. 5 0
      ChangeLog
  2. 2 1
      lib/ehandle.c

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+2008-08-05  Guillem Jover  <guillem@debian.org>
+
+	* lib/ehandle.c: Include <dpkg-priv.h>.
+	(push_cleanup): Use sizeof_array instead of ad-hoc calculation.
+
 2008-08-05  Guillem Jover  <guillem@debian.org>
 2008-08-05  Guillem Jover  <guillem@debian.org>
 
 
 	* scripts/dpkg-scanpackages.pl: Use usageerr instead of embedded code.
 	* scripts/dpkg-scanpackages.pl: Use usageerr instead of embedded code.

+ 2 - 1
lib/ehandle.c

@@ -30,6 +30,7 @@
 
 
 #include <dpkg.h>
 #include <dpkg.h>
 #include <dpkg-db.h>
 #include <dpkg-db.h>
+#include <dpkg-priv.h>
 
 
 static const char *errmsg; /* points to errmsgbuf or malloc'd */
 static const char *errmsg; /* points to errmsgbuf or malloc'd */
 static char errmsgbuf[4096];
 static char errmsgbuf[4096];
@@ -188,7 +189,7 @@ void push_cleanup(void (*call1)(int argc, void **argv), int mask1,
   
   
   cep= malloc(sizeof(struct cleanupentry) + sizeof(char*)*(nargs+1));
   cep= malloc(sizeof(struct cleanupentry) + sizeof(char*)*(nargs+1));
   if (!cep) {
   if (!cep) {
-    if (nargs > sizeof(emergency.args)/sizeof(void*))
+    if (nargs > sizeof_array(emergency.args))
       ohshite(_("out of memory for new cleanup entry with many arguments"));
       ohshite(_("out of memory for new cleanup entry with many arguments"));
     e= errno; cep= &emergency.ce;
     e= errno; cep= &emergency.ce;
   }
   }