Преглед изворни кода

libdpkg: Use sizeof_array instead of ad-hoc calculation

Guillem Jover пре 18 година
родитељ
комит
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>
 
 	* scripts/dpkg-scanpackages.pl: Use usageerr instead of embedded code.

+ 2 - 1
lib/ehandle.c

@@ -30,6 +30,7 @@
 
 #include <dpkg.h>
 #include <dpkg-db.h>
+#include <dpkg-priv.h>
 
 static const char *errmsg; /* points to errmsgbuf or malloc'd */
 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));
   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"));
     e= errno; cep= &emergency.ce;
   }