Explorar el Código

* Fixed a few calloc() calls that weren't using my_calloc()
* Removed bits.h and moved defines to common.h
* Added sys/types.h to common.h


svn: 1885

Bryan Drewery hace 21 años
padre
commit
8682bcd48c
Se han modificado 4 ficheros con 40 adiciones y 45 borrados
  1. 4 4
      src/binary.c
  2. 0 39
      src/bits.h
  3. 35 1
      src/common.h
  4. 1 1
      src/mod/irc.mod/mode.c

+ 4 - 4
src/binary.c

@@ -85,7 +85,7 @@ bin_checksum(const char *fname, int todo)
       if (!memcmp(buf, &settings.prefix, PREFIXLEN))
         break;
 
-    char *tmpbuf = (char *) calloc(1, SIZE_PACK);
+    char *tmpbuf = (char *) my_calloc(1, SIZE_PACK);
  
     if ((len = fread(tmpbuf, 1, SIZE_PACK, f))) {
       edpack(&settings, oldhash, PACK_ENC);
@@ -135,7 +135,7 @@ bin_checksum(const char *fname, int todo)
           fwrite(&settings.hash, SIZE_PACK, 1, newbin->f);
           sdprintf("writing pack: %d\n", SIZE_PACK);
         } else {
-          char *tmpbuf = (char *) calloc(1, SIZE_PACK);
+          char *tmpbuf = (char *) my_calloc(1, SIZE_PACK);
 
           if ((len = fread(tmpbuf, 1, SIZE_PACK, f))) {
             if (fwrite(tmpbuf, 1, len, newbin->f) != len) {
@@ -151,7 +151,7 @@ bin_checksum(const char *fname, int todo)
           fwrite(&settings.bots, SIZE_CONF, 1, newbin->f);
           sdprintf("writing conf: %d\n", SIZE_CONF);
         } else {
-          char *tmpbuf = (char *) calloc(1, SIZE_CONF);
+          char *tmpbuf = (char *) my_calloc(1, SIZE_CONF);
 
           if ((len = fread(tmpbuf, 1, SIZE_CONF, f))) {
             if (fwrite(tmpbuf, 1, len, newbin->f) != len) {
@@ -407,7 +407,7 @@ static bool check_bin_initialized(const char *fname)
 {
   int i = 0;
   size_t len = strlen(fname) + 3 + 1;
-  char *path = (char *) calloc(1, len);
+  char *path = (char *) my_calloc(1, len);
 
   egg_snprintf(path, len, "%s -p", fname);
 

+ 0 - 39
src/bits.h

@@ -1,39 +0,0 @@
-#ifndef _BITS_H
-#define _BITS_H
-
-#include <sys/types.h>
-
-#define BIT0	(uint32_t) 0x000000001
-#define BIT1	(uint32_t) 0x000000002
-#define BIT2	(uint32_t) 0x000000004
-#define BIT3	(uint32_t) 0x000000008
-#define BIT4	(uint32_t) 0x000000010
-#define BIT5	(uint32_t) 0x000000020
-#define BIT6	(uint32_t) 0x000000040
-#define BIT7	(uint32_t) 0x000000080
-#define BIT8	(uint32_t) 0x000000100
-#define BIT9	(uint32_t) 0x000000200
-#define BIT10	(uint32_t) 0x000000400
-#define BIT11	(uint32_t) 0x000000800
-#define BIT12	(uint32_t) 0x000001000
-#define BIT13	(uint32_t) 0x000002000
-#define BIT14	(uint32_t) 0x000004000
-#define BIT15	(uint32_t) 0x000008000
-#define BIT16	(uint32_t) 0x000010000
-#define BIT17	(uint32_t) 0x000020000
-#define BIT18	(uint32_t) 0x000040000
-#define BIT19	(uint32_t) 0x000080000
-#define BIT20	(uint32_t) 0x000100000
-#define BIT21	(uint32_t) 0x000200000
-#define BIT22	(uint32_t) 0x000400000
-#define BIT23	(uint32_t) 0x000800000
-#define BIT24	(uint32_t) 0x001000000
-#define BIT25	(uint32_t) 0x002000000
-#define BIT26	(uint32_t) 0x004000000
-#define BIT27	(uint32_t) 0x008000000
-#define BIT28	(uint32_t) 0x010000000
-#define BIT29	(uint32_t) 0x020000000
-#define BIT30	(uint32_t) 0x040000000
-#define BIT31	(uint32_t) 0x080000000
-
-#endif /* !_BITS_H */

+ 35 - 1
src/common.h

@@ -12,7 +12,6 @@
 #  include "config.h"
 #endif
 
-#include "bits.h"
 #include "garble.h"
 #include "conf.h"
 #include "debug.h"
@@ -30,6 +29,7 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <sys/types.h>
 #include <string.h>
 #include <errno.h>
 #ifdef HAVE_STRINGS_H
@@ -49,4 +49,38 @@
 */
 #endif /* WIN32 */
 
+#define BIT0    (uint32_t) 0x000000001
+#define BIT1    (uint32_t) 0x000000002
+#define BIT2    (uint32_t) 0x000000004
+#define BIT3    (uint32_t) 0x000000008
+#define BIT4    (uint32_t) 0x000000010
+#define BIT5    (uint32_t) 0x000000020
+#define BIT6    (uint32_t) 0x000000040
+#define BIT7    (uint32_t) 0x000000080
+#define BIT8    (uint32_t) 0x000000100
+#define BIT9    (uint32_t) 0x000000200
+#define BIT10   (uint32_t) 0x000000400
+#define BIT11   (uint32_t) 0x000000800
+#define BIT12   (uint32_t) 0x000001000
+#define BIT13   (uint32_t) 0x000002000
+#define BIT14   (uint32_t) 0x000004000
+#define BIT15   (uint32_t) 0x000008000
+#define BIT16   (uint32_t) 0x000010000
+#define BIT17   (uint32_t) 0x000020000
+#define BIT18   (uint32_t) 0x000040000
+#define BIT19   (uint32_t) 0x000080000
+#define BIT20   (uint32_t) 0x000100000
+#define BIT21   (uint32_t) 0x000200000
+#define BIT22   (uint32_t) 0x000400000
+#define BIT23   (uint32_t) 0x000800000
+#define BIT24   (uint32_t) 0x001000000
+#define BIT25   (uint32_t) 0x002000000
+#define BIT26   (uint32_t) 0x004000000
+#define BIT27   (uint32_t) 0x008000000
+#define BIT28   (uint32_t) 0x010000000
+#define BIT29   (uint32_t) 0x020000000
+#define BIT30   (uint32_t) 0x040000000
+#define BIT31   (uint32_t) 0x080000000
+
+
 #endif				/* _COMMON_H */

+ 1 - 1
src/mod/irc.mod/mode.c

@@ -92,7 +92,7 @@ do_op(char *nick, struct chanset_t *chan, time_t delay, bool force)
 
   if (delay) {
     egg_timeval_t howlong;
-    autoop_t *auto_op = (autoop_t *) calloc(1, sizeof(autoop_t));
+    autoop_t *auto_op = (autoop_t *) my_calloc(1, sizeof(autoop_t));
     char buf[51] = "";
 
     howlong.sec = 6;