From 1b0d1ddb319d84170cae3d639cea3005d7b96572 Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 1 Jan 2015 20:09:33 +0000 Subject: [PATCH] - Renamed MyMalloc() to xcalloc() git-svn-id: svn://svn.ircd-hybrid.org/svnroot/hopm/branches/1.0.x@5275 82007160-df01-0410-b94d-b575c5fd34c7 --- src/config-parser.c | 12 ++++++------ src/config-parser.y | 12 ++++++------ src/config.c | 8 ++++---- src/dnsbl.c | 2 +- src/firedns.c | 4 ++-- src/irc.c | 4 ++-- src/libopm/src/config.c | 8 ++++---- src/libopm/src/libopm.c | 16 ++++++++-------- src/libopm/src/list.c | 4 ++-- src/libopm/src/malloc.c | 6 +++--- src/libopm/src/malloc.h | 4 ++-- src/list.c | 4 ++-- src/main.c | 4 ++-- src/malloc.c | 6 +++--- src/malloc.h | 2 +- src/negcache.c | 4 ++-- src/opercmd.c | 2 +- src/scan.c | 6 +++--- 18 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/config-parser.c b/src/config-parser.c index 12cf97e..78b57f7 100644 --- a/src/config-parser.c +++ b/src/config-parser.c @@ -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)); diff --git a/src/config-parser.y b/src/config-parser.y index 297dbc9..2f7ae5c 100644 --- a/src/config-parser.y +++ b/src/config-parser.y @@ -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); diff --git a/src/config.c b/src/config.c index 8eba798..f89686e 100644 --- a/src/config.c +++ b/src/config.c @@ -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(); } diff --git a/src/dnsbl.c b/src/dnsbl.c index 3508ab3..f0c8f56 100644 --- a/src/dnsbl.c +++ b/src/dnsbl.c @@ -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; diff --git a/src/firedns.c b/src/firedns.c index f698c01..29266a3 100644 --- a/src/firedns.c +++ b/src/firedns.c @@ -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; diff --git a/src/irc.c b/src/irc.c index 1afd6da..d030ee4 100644 --- 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))) { diff --git a/src/libopm/src/config.c b/src/libopm/src/config.c index a32b980..93727de 100644 --- a/src/libopm/src/config.c +++ b/src/libopm/src/config.c @@ -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; diff --git a/src/libopm/src/libopm.c b/src/libopm/src/libopm.c index 4e3ea07..7bcf4dc 100644 --- a/src/libopm/src/libopm.c +++ b/src/libopm/src/libopm.c @@ -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)); } diff --git a/src/libopm/src/list.c b/src/libopm/src/list.c index 462a41e..8e0a72d 100644 --- a/src/libopm/src/list.c +++ b/src/libopm/src/list.c @@ -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; diff --git a/src/libopm/src/malloc.c b/src/libopm/src/malloc.c index 0749ba4..f7988b4 100644 --- a/src/libopm/src/malloc.c +++ b/src/libopm/src/malloc.c @@ -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 diff --git a/src/libopm/src/malloc.h b/src/libopm/src/malloc.h index fcba664..4e4a79c 100644 --- a/src/libopm/src/malloc.h +++ b/src/libopm/src/malloc.h @@ -5,10 +5,10 @@ #include -#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 *); diff --git a/src/list.c b/src/list.c index 140a521..53a0a41 100644 --- a/src/list.c +++ b/src/list.c @@ -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; diff --git a/src/main.c b/src/main.c index 3fa1156..1bf793e 100644 --- a/src/main.c +++ b/src/main.c @@ -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); diff --git a/src/malloc.c b/src/malloc.c index 63b9c31..f1c34fe 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -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 diff --git a/src/malloc.h b/src/malloc.h index 7eda24f..c777064 100644 --- a/src/malloc.h +++ b/src/malloc.h @@ -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 *); diff --git a/src/negcache.c b/src/negcache.c index abd5010..f77bc79 100644 --- a/src/negcache.c +++ b/src/negcache.c @@ -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; diff --git a/src/opercmd.c b/src/opercmd.c index 8e862ea..43fa45a 100644 --- a/src/opercmd.c +++ b/src/opercmd.c @@ -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; diff --git a/src/scan.c b/src/scan.c index f13137a..48e5203 100644 --- a/src/scan.c +++ b/src/scan.c @@ -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; -- 2.30.2