- Renamed MyMalloc() to xcalloc()
authormichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>
Thu, 1 Jan 2015 20:09:33 +0000 (20:09 +0000)
committermichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>
Thu, 1 Jan 2015 20:09:33 +0000 (20:09 +0000)
git-svn-id: svn://svn.ircd-hybrid.org/svnroot/hopm/branches/1.0.x@5275 82007160-df01-0410-b94d-b575c5fd34c7

18 files changed:
src/config-parser.c
src/config-parser.y
src/config.c
src/dnsbl.c
src/firedns.c
src/irc.c
src/libopm/src/config.c
src/libopm/src/libopm.c
src/libopm/src/list.c
src/libopm/src/malloc.c
src/libopm/src/malloc.h
src/list.c
src/main.c
src/malloc.c
src/malloc.h
src/negcache.c
src/opercmd.c
src/scan.c

index 12cf97e947806188c299f4fca501edb29d3055e8..78b57f78e3f08470aa570223755b331c5ce8c223 100644 (file)
@@ -1826,7 +1826,7 @@ yyreduce:
    node_t *node;
    struct ChannelConf *item;
 
-   item = MyMalloc(sizeof *item);
+   item = xcalloc(sizeof *item);
 
    item->name = xstrdup("");
    item->key = xstrdup("");
@@ -1879,7 +1879,7 @@ yyreduce:
    node_t *node;
    struct UserConf *item;
 
-   item = MyMalloc(sizeof *item);
+   item = xcalloc(sizeof *item);
 
    item->masks = list_create();
    item->scanners = list_create();
@@ -1924,7 +1924,7 @@ yyreduce:
    node_t *node;
    struct ScannerConf *item, *olditem;
 
-   item = MyMalloc(sizeof *item);
+   item = xcalloc(sizeof *item);
 
    /* Setup ScannerConf defaults */
    item->name = xstrdup("undefined");
@@ -2059,7 +2059,7 @@ yyreduce:
 
    node_t *node;
  
-   item = MyMalloc(sizeof *item);
+   item = xcalloc(sizeof *item);
    item->type = (yyvsp[-3].number);
    item->port = (yyvsp[-1].number);
 
@@ -2104,7 +2104,7 @@ yyreduce:
    node_t *node;
    struct BlacklistConf *item;
 
-   item = MyMalloc(sizeof *item);
+   item = xcalloc(sizeof *item);
 
    item->name = xstrdup("");
    item->kline = xstrdup("");
@@ -2174,7 +2174,7 @@ yyreduce:
    struct BlacklistConf *blacklist = tmp;
    node_t *node;
 
-   item = MyMalloc(sizeof *item);
+   item = xcalloc(sizeof *item);
 
    item->number = (yyvsp[-3].number);
    item->type = xstrdup((yyvsp[-1].string));
index 297dbc9edd56e5c6d3875ba1a7c7ac8e6cc90f56..2f7ae5c5fb5fa60df2bddaace4e33c121bda068b 100644 (file)
@@ -285,7 +285,7 @@ channel_entry:
    node_t *node;
    struct ChannelConf *item;
 
-   item = MyMalloc(sizeof *item);
+   item = xcalloc(sizeof *item);
 
    item->name = xstrdup("");
    item->key = xstrdup("");
@@ -336,7 +336,7 @@ user_entry:
    node_t *node;
    struct UserConf *item;
 
-   item = MyMalloc(sizeof *item);
+   item = xcalloc(sizeof *item);
 
    item->masks = list_create();
    item->scanners = list_create();
@@ -382,7 +382,7 @@ scanner_entry:
    node_t *node;
    struct ScannerConf *item, *olditem;
 
-   item = MyMalloc(sizeof *item);
+   item = xcalloc(sizeof *item);
 
    /* Setup ScannerConf defaults */
    item->name = xstrdup("undefined");
@@ -505,7 +505,7 @@ scanner_protocol: PROTOCOL '=' PROTOCOLTYPE ':' NUMBER ';'
 
    node_t *node;
  
-   item = MyMalloc(sizeof *item);
+   item = xcalloc(sizeof *item);
    item->type = $3;
    item->port = $5;
 
@@ -553,7 +553,7 @@ opm_blacklist_entry:
    node_t *node;
    struct BlacklistConf *item;
 
-   item = MyMalloc(sizeof *item);
+   item = xcalloc(sizeof *item);
 
    item->name = xstrdup("");
    item->kline = xstrdup("");
@@ -620,7 +620,7 @@ blacklist_reply_item: NUMBER '=' STRING ';'
    struct BlacklistConf *blacklist = tmp;
    node_t *node;
 
-   item = MyMalloc(sizeof *item);
+   item = xcalloc(sizeof *item);
 
    item->number = $1;
    item->type = xstrdup($3);
index 8eba7986a0dd55f5da3edcda1d5b86f47446826b..f89686e21d270d218925ca39b2b4d5329bd56fa7 100644 (file)
@@ -52,15 +52,15 @@ void
 config_init(void)
 {
   /* Init IRC block */
-  IRCItem = MyMalloc(sizeof *IRCItem);
+  IRCItem = xcalloc(sizeof *IRCItem);
   IRCItem->channels = list_create();
   IRCItem->performs = list_create();
 
   /* Init Options block */
-  OptionsItem = MyMalloc(sizeof *OptionsItem);
+  OptionsItem = xcalloc(sizeof *OptionsItem);
 
   /* Init OPM block */
-  OpmItem = MyMalloc(sizeof *OpmItem);
+  OpmItem = xcalloc(sizeof *OpmItem);
   OpmItem->blacklists = list_create();
 
   /* Init list of User blocks */
@@ -70,7 +70,7 @@ config_init(void)
   ScannerItemList = list_create();
 
   /* Init list of Exempts */
-  ExemptItem = MyMalloc(sizeof *ExemptItem);
+  ExemptItem = xcalloc(sizeof *ExemptItem);
   ExemptItem->masks = list_create();
 }
 
index 3508ab30726a44197d57169a7d5c7513f4678e23..f0c8f5649346590ad8da4491c0e6db7ea4208529 100644 (file)
@@ -80,7 +80,7 @@ dnsbl_add(struct scan_struct *ss)
     snprintf(lookup, 128, "%d.%d.%d.%d.%s", d, c, b, a, bl->name);
 #endif
 
-    ds = MyMalloc(sizeof *ds);
+    ds = xcalloc(sizeof *ds);
     ds->ss = ss;
     ds->bl = bl;
 
index f698c011b87f98d776843c2696b5ca46ed734278..29266a38476276b08f4255d6b4c279c6219815e6 100644 (file)
@@ -357,7 +357,7 @@ firedns_add_query(void)
   struct s_connection *s;
 
   /* create new connection object */
-  s = MyMalloc(sizeof *s);
+  s = xcalloc(sizeof *s);
 
   /* verified by firedns_getresult() */
   s->id[0] = rand() % 255;
@@ -775,7 +775,7 @@ firedns_cycle(void)
     return;
 
   if (ufds == NULL)
-    ufds = MyMalloc((sizeof *ufds) * OptionsItem->dns_fdlimit);
+    ufds = xcalloc((sizeof *ufds) * OptionsItem->dns_fdlimit);
 
   time(&timenow);
   size = 0;
index 1afd6da19752924cc0b615ac8b29bcd052bf3b5c..d030ee4ac458da15d3b2d27f9a85d59aca8d05bb 100644 (file)
--- a/src/irc.c
+++ b/src/irc.c
@@ -644,7 +644,7 @@ userinfo_create(char *source)
     return NULL;
   }
 
-  ret = MyMalloc(sizeof *ret);
+  ret = xcalloc(sizeof *ret);
   ret->irc_nick     = xstrdup(nick);
   ret->irc_username = xstrdup(username);
   ret->irc_hostname = xstrdup(hostname);
@@ -873,7 +873,7 @@ m_notice(char **parv, unsigned int parc, char *msg, struct UserInfo *source_p)
   /* Compile the regular expression if it has not been already */
   if (preg == NULL)
   {
-    preg = MyMalloc(sizeof *preg);
+    preg = xcalloc(sizeof *preg);
 
     if ((errnum = regcomp(preg, IRCItem->connregex, REG_ICASE | REG_EXTENDED)))
     {
index a32b9802dba44800905c4ef0f81da8aea240ff93..93727ded9699f74121e56269e396e0c124ba69b7 100644 (file)
@@ -64,8 +64,8 @@ OPM_CONFIG_T *libopm_config_create()
 
    num = sizeof(HASH) / sizeof(OPM_CONFIG_HASH_T);
 
-   ret = MyMalloc(sizeof(OPM_CONFIG_T));
-   ret->vars = MyMalloc(sizeof(void *) * num);
+   ret = xcalloc(sizeof(OPM_CONFIG_T));
+   ret->vars = xcalloc(sizeof(void *) * num);
 
 
    /* Set default config items. This in the future would be much better
@@ -82,7 +82,7 @@ OPM_CONFIG_T *libopm_config_create()
       switch(libopm_config_gettype(i))
       {
          case OPM_TYPE_INT:
-            ret->vars[i] = MyMalloc(sizeof(int));
+            ret->vars[i] = xcalloc(sizeof(int));
             *(int *) ret->vars[i] = 0;
             break;
 
@@ -91,7 +91,7 @@ OPM_CONFIG_T *libopm_config_create()
             break;
 
          case OPM_TYPE_ADDRESS:
-            ret->vars[i] = MyMalloc(sizeof(opm_sockaddr));
+            ret->vars[i] = xcalloc(sizeof(opm_sockaddr));
             memset((opm_sockaddr *) ret->vars[i], 0, sizeof(opm_sockaddr));
             break; 
 
index 4e3ea07ec4b75d4ce922a2f621bd842cf5fa1717..7bcf4dcd2bb37bb1dc15f281f6fe0c7e8db6a947 100644 (file)
@@ -112,7 +112,7 @@ OPM_T *opm_create()
    int i;
    OPM_T *ret;
 
-   ret = MyMalloc(sizeof *ret);
+   ret = xcalloc(sizeof *ret);
 
    ret->config = libopm_config_create();
    ret->scans = libopm_list_create();
@@ -121,7 +121,7 @@ OPM_T *opm_create()
    ret->fd_use = 0;
 
    /* Setup callbacks */
-   ret->callbacks = MyMalloc(sizeof(OPM_CALLBACK_T) * CBLEN);
+   ret->callbacks = xcalloc(sizeof(OPM_CALLBACK_T) * CBLEN);
    for(i = 0; i < CBLEN; i++)
    {
       ret->callbacks[i].func = NULL;
@@ -152,7 +152,7 @@ OPM_REMOTE_T *opm_remote_create(const char *ip)
    OPM_REMOTE_T *ret;
 
 
-   ret = MyMalloc(sizeof *ret);
+   ret = xcalloc(sizeof *ret);
 
    /* Do initializations */
    if(ip == NULL)
@@ -411,7 +411,7 @@ OPM_ERR_T opm_remote_addtype(OPM_REMOTE_T *remote, int type, unsigned short int
 static OPM_PROTOCOL_T *libopm_protocol_create(void)
 {
    OPM_PROTOCOL_T *ret;
-   ret = MyMalloc(sizeof(OPM_PROTOCOL_T));
+   ret = xcalloc(sizeof(OPM_PROTOCOL_T));
 
    ret->type           = 0;
    ret->write_function = NULL;
@@ -461,7 +461,7 @@ static void libopm_protocol_free(OPM_PROTOCOL_T *protocol)
 static OPM_PROTOCOL_CONFIG_T *libopm_protocol_config_create(void)
 {
    OPM_PROTOCOL_CONFIG_T *ret;
-   ret = MyMalloc(sizeof *ret);
+   ret = xcalloc(sizeof *ret);
 
    return ret;
 }
@@ -672,7 +672,7 @@ static OPM_SCAN_T *libopm_scan_create(OPM_T *scanner, OPM_REMOTE_T *remote)
    OPM_CONNECTION_T *conn;
    OPM_NODE_T *node, *p;
 
-   ret = MyMalloc(sizeof *ret);
+   ret = xcalloc(sizeof *ret);
 
    ret->remote = remote;
    ret->connections = libopm_list_create();
@@ -759,7 +759,7 @@ static void libopm_scan_free(OPM_SCAN_T *scan)
 static OPM_CONNECTION_T *libopm_connection_create(void)
 {
    OPM_CONNECTION_T *ret;
-   ret = MyMalloc(sizeof *ret);
+   ret = xcalloc(sizeof *ret);
 
    ret->fd         = 0;
    ret->bytes_read = 0;
@@ -1085,7 +1085,7 @@ static void libopm_check_poll(OPM_T *scanner)
    if(ufds_size < (*(unsigned int *) libopm_config(scanner->config, OPM_CONFIG_FD_LIMIT)))
    {
       MyFree(ufds);
-      ufds = MyMalloc((sizeof *ufds) * (*(unsigned int *) libopm_config(scanner->config, OPM_CONFIG_FD_LIMIT)));
+      ufds = xcalloc((sizeof *ufds) * (*(unsigned int *) libopm_config(scanner->config, OPM_CONFIG_FD_LIMIT)));
       ufds_size = (*(unsigned int *) libopm_config(scanner->config, OPM_CONFIG_FD_LIMIT));
    }
 
index 462a41e89d073a9c0b3c99897f3a87df9e968659..8e0a72d4980797d703504b5044f92afbb9e30e37 100644 (file)
@@ -31,7 +31,7 @@
 
 OPM_NODE_T *libopm_node_create(void *data)
 {
-   OPM_NODE_T *node = MyMalloc(sizeof *node);
+   OPM_NODE_T *node = xcalloc(sizeof *node);
    node->next = NULL;
    node->prev = NULL;  
    node->data = (void *) data;
@@ -41,7 +41,7 @@ OPM_NODE_T *libopm_node_create(void *data)
 
 OPM_LIST_T *libopm_list_create()
 {
-   OPM_LIST_T *list = MyMalloc(sizeof *list);
+   OPM_LIST_T *list = xcalloc(sizeof *list);
 
    list->head = NULL;
    list->tail = NULL;
index 0749ba4ad4a7675422c1d20c7da7987e9119cdf3..f7988b45538427067288d02f430afd65693b8a55 100644 (file)
@@ -29,7 +29,7 @@
 #include "opm.h"
 
 
-/* MyMalloc
+/* xcalloc
  *  
  *   A wrapper function for malloc(), for catching memory issues
  *   and error handling.
@@ -41,7 +41,7 @@
  *    Pointer to allocated memory
  */
 
-void *libopm_MyMalloc(size_t bytes)
+void *libopm_xcalloc(size_t bytes)
 {
    void *ret = calloc(1, bytes);
 
@@ -54,7 +54,7 @@ void *libopm_MyMalloc(size_t bytes)
 
 /*  MyFree
  *
- *  Free memory allocated with MyMalloc
+ *  Free memory allocated with xcalloc
  *
  *  Parameters:
  *     var: pointer to memory to free
index fcba6648690f301166fadbe9318eebd4d9ec27b3..4e4a79c07f2a71a2143e256fed5bbbc10b8ca5c9 100644 (file)
@@ -5,10 +5,10 @@
 
 #include <stdlib.h>
 
-#define MyMalloc(SIZE) libopm_MyMalloc(SIZE)
+#define xcalloc(SIZE) libopm_xcalloc(SIZE)
 #define MyFree(X) libopm_MyFree((void **) &X)
 
-void *libopm_MyMalloc(size_t bytes);
+void *libopm_xcalloc(size_t bytes);
 void libopm_MyFree(void **var);
 extern void *libopm_xstrdup(const char *);
 
index 140a521de0b0d286fdce34e59901294db045fabc..53a0a41307a39a1279d89a12a277ada13b2b9c7d 100644 (file)
@@ -27,7 +27,7 @@
 
 node_t *node_create(void *data)
 {
-   node_t *node = MyMalloc(sizeof *node);
+   node_t *node = xcalloc(sizeof *node);
    node->next = NULL;
    node->prev = NULL;
    node->data = (void *) data;
@@ -37,7 +37,7 @@ node_t *node_create(void *data)
 
 list_t *list_create()
 {
-   list_t *list = MyMalloc(sizeof *list);
+   list_t *list = xcalloc(sizeof *list);
 
    list->head = NULL;
    list->tail = NULL;
index 3fa1156e3f95499b669f410d8e7c1700d58bae5a..1bf793eb2c8c2f14da648b7a697b7224ad288a95 100644 (file)
@@ -116,8 +116,8 @@ main(int argc, char *argv[])
   lenc = strlen(CONFDIR) + strlen(CONFNAME) + strlen(CONFEXT) + 3;
   lenl = strlen(LOGDIR) + strlen(CONFNAME) + strlen(LOGEXT) + 3;
 
-  CONFFILE = MyMalloc(lenc * sizeof *CONFFILE);
-  LOGFILE = MyMalloc(lenl * sizeof *LOGFILE);
+  CONFFILE = xcalloc(lenc * sizeof *CONFFILE);
+  LOGFILE = xcalloc(lenl * sizeof *LOGFILE);
 
   snprintf(CONFFILE, lenc, "%s/%s.%s", CONFDIR, CONFNAME, CONFEXT);
   snprintf(LOGFILE, lenl, "%s/%s.%s", LOGDIR, CONFNAME, LOGEXT);
index 63b9c3139c1cc0391186b29f5f8dbf6e08518302..f1c34fe8bd45e4a5544250cbb2effd29d22d8fca 100644 (file)
@@ -27,7 +27,7 @@
 #include "malloc.h"
 
 
-/* MyMalloc
+/* xcalloc
  *  
  *   A wrapper function for malloc(), for catching memory issues
  *   and error handling.
@@ -39,7 +39,7 @@
  *    Pointer to allocated memory
  */
 
-void *MyMalloc(size_t bytes)
+void *xcalloc(size_t bytes)
 {
    void *ret = calloc(1, bytes);
    assert(ret);
@@ -51,7 +51,7 @@ void *MyMalloc(size_t bytes)
 
 /*  MyFree
  *
- *  Free memory allocated with MyMalloc
+ *  Free memory allocated with xcalloc
  *
  *  Parameters:
  *     var: pointer to memory to free
index 7eda24f30f2ca26373386fa0bbd8f3054594423c..c777064b343393d9d2c0edee04e33a4299486e03 100644 (file)
@@ -5,7 +5,7 @@
 
 #define MyFree(X) _MyFree((void **) &X)
 
-extern void *MyMalloc(size_t bytes);
+extern void *xcalloc(size_t bytes);
 extern void _MyFree(void **var);
 extern void *xstrdup(const char *);
 
index abd5010166327b9b57eba4eccaa99678ef4db7fc..f77bc7902fad1cdd0b809e3ef18a15b272770121 100644 (file)
@@ -80,7 +80,7 @@ void nc_init(struct cnode **head)
       return;
    }
 
-   *head = MyMalloc(sizeof **head);
+   *head = xcalloc(sizeof **head);
 
    maxb = (sizeof((*head)->ip) * 8);
    (*head)->ip = 0;
@@ -149,7 +149,7 @@ static struct cnode *nc_insert(struct cnode *head, const unsigned long ip)
       x = GETBIT(ip, x->b) ? x->r : x->l;
    }
 
-   t = MyMalloc(sizeof *t);
+   t = xcalloc(sizeof *t);
    t->ip = ip;
    t->b = i;
    t->l = GETBIT(ip, t->b) ? x : t;
index 8e862ea2088b179feac789ba9ffcdbeaba2c813e..43fa45aa4e7f418f314c8a861de4fb9c1586f676 100644 (file)
@@ -210,7 +210,7 @@ command_parse(char *command, char *msg, struct ChannelConf *target,
 static struct Command *
 command_create(unsigned short type, char *param, char *irc_nick, struct ChannelConf *target)
 {
-  struct Command *ret = MyMalloc(sizeof *ret);
+  struct Command *ret = xcalloc(sizeof *ret);
 
   ret->type = type;
 
index f13137a530aba5ab0dfbeb54d44831d65b73fef5..48e52037a9037a367f8c2331d5ae675259a89097 100644 (file)
@@ -197,7 +197,7 @@ scan_init(void)
   LIST_FOREACH(p, ScannerItemList->head)
   {
     sc = p->data;
-    scs = MyMalloc(sizeof *scs);
+    scs = xcalloc(sizeof *scs);
 
     if (OPT_DEBUG)
       log_printf("SCAN -> Setting up scanner [%s]", sc->name);
@@ -429,7 +429,7 @@ scan_connect(char **user, char *msg)
 struct scan_struct *
 scan_create(char **user, char *msg)
 {
-  struct scan_struct *ss = MyMalloc(sizeof *ss);
+  struct scan_struct *ss = xcalloc(sizeof *ss);
 
   ss->irc_nick = xstrdup(user[0]);
   ss->irc_username = xstrdup(user[1]);
@@ -917,7 +917,7 @@ scan_manual(char *param, struct ChannelConf *target)
   /* IP = the resolved IP now (it was the ip OR hostname before) */
   ip = inet_ntoa(*addr);
 
-  ss = MyMalloc(sizeof *ss);
+  ss = xcalloc(sizeof *ss);
 
   /* These don't exist in a manual scan */
   ss->irc_nick     = NULL;