node_t *node;
struct ChannelConf *item;
- item = MyMalloc(sizeof *item);
+ item = xcalloc(sizeof *item);
item->name = xstrdup("");
item->key = xstrdup("");
node_t *node;
struct UserConf *item;
- item = MyMalloc(sizeof *item);
+ item = xcalloc(sizeof *item);
item->masks = list_create();
item->scanners = list_create();
node_t *node;
struct ScannerConf *item, *olditem;
- item = MyMalloc(sizeof *item);
+ item = xcalloc(sizeof *item);
/* Setup ScannerConf defaults */
item->name = xstrdup("undefined");
node_t *node;
- item = MyMalloc(sizeof *item);
+ item = xcalloc(sizeof *item);
item->type = (yyvsp[-3].number);
item->port = (yyvsp[-1].number);
node_t *node;
struct BlacklistConf *item;
- item = MyMalloc(sizeof *item);
+ item = xcalloc(sizeof *item);
item->name = xstrdup("");
item->kline = xstrdup("");
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));
node_t *node;
struct ChannelConf *item;
- item = MyMalloc(sizeof *item);
+ item = xcalloc(sizeof *item);
item->name = xstrdup("");
item->key = xstrdup("");
node_t *node;
struct UserConf *item;
- item = MyMalloc(sizeof *item);
+ item = xcalloc(sizeof *item);
item->masks = list_create();
item->scanners = list_create();
node_t *node;
struct ScannerConf *item, *olditem;
- item = MyMalloc(sizeof *item);
+ item = xcalloc(sizeof *item);
/* Setup ScannerConf defaults */
item->name = xstrdup("undefined");
node_t *node;
- item = MyMalloc(sizeof *item);
+ item = xcalloc(sizeof *item);
item->type = $3;
item->port = $5;
node_t *node;
struct BlacklistConf *item;
- item = MyMalloc(sizeof *item);
+ item = xcalloc(sizeof *item);
item->name = xstrdup("");
item->kline = xstrdup("");
struct BlacklistConf *blacklist = tmp;
node_t *node;
- item = MyMalloc(sizeof *item);
+ item = xcalloc(sizeof *item);
item->number = $1;
item->type = xstrdup($3);
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 */
ScannerItemList = list_create();
/* Init list of Exempts */
- ExemptItem = MyMalloc(sizeof *ExemptItem);
+ ExemptItem = xcalloc(sizeof *ExemptItem);
ExemptItem->masks = list_create();
}
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;
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;
return;
if (ufds == NULL)
- ufds = MyMalloc((sizeof *ufds) * OptionsItem->dns_fdlimit);
+ ufds = xcalloc((sizeof *ufds) * OptionsItem->dns_fdlimit);
time(&timenow);
size = 0;
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);
/* 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)))
{
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
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;
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;
int i;
OPM_T *ret;
- ret = MyMalloc(sizeof *ret);
+ ret = xcalloc(sizeof *ret);
ret->config = libopm_config_create();
ret->scans = libopm_list_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;
OPM_REMOTE_T *ret;
- ret = MyMalloc(sizeof *ret);
+ ret = xcalloc(sizeof *ret);
/* Do initializations */
if(ip == NULL)
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;
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;
}
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();
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;
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));
}
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;
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;
#include "opm.h"
-/* MyMalloc
+/* xcalloc
*
* A wrapper function for malloc(), for catching memory issues
* and error handling.
* Pointer to allocated memory
*/
-void *libopm_MyMalloc(size_t bytes)
+void *libopm_xcalloc(size_t bytes)
{
void *ret = calloc(1, bytes);
/* MyFree
*
- * Free memory allocated with MyMalloc
+ * Free memory allocated with xcalloc
*
* Parameters:
* var: pointer to memory to free
#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 *);
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;
list_t *list_create()
{
- list_t *list = MyMalloc(sizeof *list);
+ list_t *list = xcalloc(sizeof *list);
list->head = NULL;
list->tail = NULL;
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);
#include "malloc.h"
-/* MyMalloc
+/* xcalloc
*
* A wrapper function for malloc(), for catching memory issues
* and error handling.
* Pointer to allocated memory
*/
-void *MyMalloc(size_t bytes)
+void *xcalloc(size_t bytes)
{
void *ret = calloc(1, bytes);
assert(ret);
/* MyFree
*
- * Free memory allocated with MyMalloc
+ * Free memory allocated with xcalloc
*
* Parameters:
* var: pointer to memory to free
#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 *);
return;
}
- *head = MyMalloc(sizeof **head);
+ *head = xcalloc(sizeof **head);
maxb = (sizeof((*head)->ip) * 8);
(*head)->ip = 0;
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;
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;
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);
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]);
/* 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;