Entirely automatic conversion, using the following Perl rune:
perl -i~ -pe 's#^(\s+)(\w+)=safe_malloc\(sizeof\(\*\2\),"[^"]+"\);$#$1NEW($2);#' *.c conffile.fl conffile.y
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
21 files changed:
struct commcommon *st=commst;
struct comm_notify_entry *n;
struct commcommon *st=commst;
struct comm_notify_entry *n;
- n=safe_malloc(sizeof(*n),"comm_request_notify");
n->fn=fn;
n->state=nst;
LIST_INSERT_HEAD(&st->notify, n, entry);
n->fn=fn;
n->state=nst;
LIST_INSERT_HEAD(&st->notify, n, entry);
if (dict_ilookup_primitive(dict, key)) {
fatal("duplicate key \"%s\" in dictionary",key);
}
if (dict_ilookup_primitive(dict, key)) {
fatal("duplicate key \"%s\" in dictionary",key);
}
- e=safe_malloc(sizeof(*e),"dict_add");
e->next=dict->entries;
e->key=key;
e->val=val;
e->next=dict->entries;
e->key=key;
e->val=val;
- d=safe_malloc(sizeof(*d),"dict_new");
d->parent=parent;
d->search=NULL;
d->entries=NULL;
d->parent=parent;
d->search=NULL;
d->entries=NULL;
static struct p_node *node_copy(struct p_node *n)
{
struct p_node *r;
static struct p_node *node_copy(struct p_node *n)
{
struct p_node *r;
- r=safe_malloc(sizeof(*r),"node_copy");
- i=safe_malloc(sizeof(*i),"new_item");
i->type=type;
i->loc=loc;
return i;
i->type=type;
i->loc=loc;
return i;
if (!i) {
/* Did't find it; create a new one */
if (!i) {
/* Did't find it; create a new one */
- i=safe_malloc(sizeof(*i),"intern: alloc list entry");
i->a=safe_strdup(s,"intern: alloc string");
i->next=atoms;
atoms=i;
i->a=safe_strdup(s,"intern: alloc string");
i->next=atoms;
atoms=i;
l=NULL;
r=NULL;
for (i=a; i; i=i->next) {
l=NULL;
r=NULL;
for (i=a; i; i=i->next) {
- b=safe_malloc(sizeof(*b),"list_copy");
if (l) l->next=b; else r=b;
l=b;
b->item=i->item;
if (l) l->next=b; else r=b;
l=b;
b->item=i->item;
- l=safe_malloc(sizeof(*l),"list_append");
l->item=item;
l->next=NULL;
l->item=item;
l->next=NULL;
void add_closure(dict_t *dict, cstring_t name, apply_fn apply)
{
closure_t *c;
void add_closure(dict_t *dict, cstring_t name, apply_fn apply)
{
closure_t *c;
- c=safe_malloc(sizeof(*c),"add_closure");
c->description=name;
c->type=CL_PURE;
c->apply=apply;
c->description=name;
c->type=CL_PURE;
c->apply=apply;
- r=safe_malloc(sizeof(*r),"leafnode");
r->type=type;
r->loc.file=config_file;
r->loc.line=config_lineno;
r->type=type;
r->loc.file=config_file;
r->loc.line=config_lineno;
- rv=safe_malloc(sizeof(*rv),"p_node");
rv->type=type;
rv->loc.file=config_file;
rv->loc.line=config_lineno;
rv->type=type;
rv->loc.file=config_file;
rv->loc.line=config_lineno;
- st=safe_malloc(sizeof(*st),"dh_apply");
st->cl.description="dh";
st->cl.type=CL_DH;
st->cl.apply=NULL;
st->cl.description="dh";
st->cl.type=CL_DH;
st->cl.apply=NULL;
struct subnet_list *subnet_list_new(void)
{
struct subnet_list *r;
struct subnet_list *subnet_list_new(void)
{
struct subnet_list *r;
- r=safe_malloc(sizeof(*r),"subnet_list_new:list");
r->entries=0;
r->alloc=DEFAULT_ALLOC;
r->list=safe_malloc_ary(sizeof(*r->list),r->alloc,"subnet_list_new:data");
r->entries=0;
r->alloc=DEFAULT_ALLOC;
r->list=safe_malloc_ary(sizeof(*r->list),r->alloc,"subnet_list_new:data");
struct ipset *ipset_new(void)
{
struct ipset *r;
struct ipset *ipset_new(void)
{
struct ipset *r;
- r=safe_malloc(sizeof(*r),"ipset_new:set");
r->l=0;
r->a=DEFAULT_ALLOC;
r->d=safe_malloc(sizeof(*r->d)*r->a,"ipset_new:data");
r->l=0;
r->a=DEFAULT_ALLOC;
r->d=safe_malloc(sizeof(*r->d)*r->a,"ipset_new:data");
if (cl->type!=CL_LOG) {
cfgfatal(item->loc,"init_log","closure is not a logger");
}
if (cl->type!=CL_LOG) {
cfgfatal(item->loc,"init_log","closure is not a logger");
}
- n=safe_malloc(sizeof(*n),"init_log");
n->l=cl->interface;
n->next=l;
l=n;
n->l=cl->interface;
n->next=l;
l=n;
phase. We should defer writing into the logfile until after we
become a daemon. */
phase. We should defer writing into the logfile until after we
become a daemon. */
- st=safe_malloc(sizeof(*st),"logfile_apply");
st->cl.description="logfile";
st->cl.type=CL_LOG;
st->cl.apply=NULL;
st->cl.description="logfile";
st->cl.type=CL_LOG;
st->cl.apply=NULL;
item_t *item;
string_t facstr;
item_t *item;
string_t facstr;
- st=safe_malloc(sizeof(*st),"syslog_apply");
st->cl.description="syslog";
st->cl.type=CL_LOG;
st->cl.apply=NULL;
st->cl.description="syslog";
st->cl.type=CL_LOG;
st->cl.apply=NULL;
- st=safe_malloc(sizeof(*st),"log_from_fd");
st->log=log;
st->fd=fd;
st->prefix=prefix;
st->log=log;
st->fd=fd;
st->prefix=prefix;
{
struct MD5Context *ctx;
{
struct MD5Context *ctx;
- ctx=safe_malloc(sizeof(*ctx),"md5_init");
MD5Init(ctx);
return ctx;
MD5Init(ctx);
return ctx;
uint8_t digest[16];
int i;
uint8_t digest[16];
int i;
- st=safe_malloc(sizeof(*st),"md5_module");
st->cl.description="md5";
st->cl.type=CL_HASH;
st->cl.apply=NULL;
st->cl.description="md5";
st->cl.type=CL_HASH;
st->cl.apply=NULL;
- c=safe_malloc(sizeof(*c),"netlink_inst_create");
c->cl.description=name;
c->cl.type=CL_NETLINK;
c->cl.apply=NULL;
c->cl.description=name;
c->cl.type=CL_NETLINK;
c->cl.apply=NULL;
item_t *item;
dict_t *dict;
item_t *item;
dict_t *dict;
- st=safe_malloc(sizeof(*st),"null_apply");
item=list_elem(args,0);
if (!item || item->type!=t_dict)
item=list_elem(args,0);
if (!item || item->type!=t_dict)
struct child *c;
pid_t p;
struct child *c;
pid_t p;
- c=safe_malloc(sizeof(*c),"makesubproc");
c->desc=desc;
c->cb=cb;
c->cst=cst;
c->desc=desc;
c->cb=cb;
c->cst=cst;
if (rv==i->pid) {
i->finished=True;
if (rv==i->pid) {
i->finished=True;
- nw=safe_malloc(sizeof(*nw),"sigchld_handler");
nw->pid=i->pid;
nw->cb=i->cb;
nw->cst=i->cst;
nw->pid=i->pid;
nw->cb=i->cb;
nw->cst=i->cst;
struct signotify *s;
sigset_t old;
struct signotify *s;
sigset_t old;
- s=safe_malloc(sizeof(*s),"request_signal_notification");
s->signum=signum;
s->notify=notify;
s->cst=cst;
s->signum=signum;
s->notify=notify;
s->cst=cst;
item_t *arg1, *arg2;
string_t filename=NULL;
item_t *arg1, *arg2;
string_t filename=NULL;
- st=safe_malloc(sizeof(*st),"random_apply");
st->cl.description="randomsource";
st->cl.type=CL_RANDOMSRC;
st->cl.description="randomsource";
st->cl.type=CL_RANDOMSRC;
item_t *i;
string_t conf;
item_t *i;
string_t conf;
- st=safe_malloc(sizeof(*st),"adnsresolver_apply");
st->cl.description="adns";
st->cl.type=CL_RESOLVER;
st->cl.apply=NULL;
st->cl.description="adns";
st->cl.type=CL_RESOLVER;
st->cl.apply=NULL;
- st=safe_malloc(sizeof(*st),"rsapub_apply");
st->cl.description="rsapub";
st->cl.type=CL_RSAPUBKEY;
st->cl.apply=NULL;
st->cl.description="rsapub";
st->cl.type=CL_RSAPUBKEY;
st->cl.apply=NULL;
MP_INT e,d,iqmp,tmp,tmp2,tmp3;
bool_t valid;
MP_INT e,d,iqmp,tmp,tmp2,tmp3;
bool_t valid;
- st=safe_malloc(sizeof(*st),"rsapriv_apply");
st->cl.description="rsapriv";
st->cl.type=CL_RSAPRIVKEY;
st->cl.apply=NULL;
st->cl.description="rsapriv";
st->cl.type=CL_RSAPRIVKEY;
st->cl.apply=NULL;
{
struct poll_interest *i;
{
struct poll_interest *i;
- i=safe_malloc(sizeof(*i),"register_for_poll");
i->before=before;
i->after=after;
i->state=st;
i->before=before;
i->after=after;
i->state=st;
- ctx=safe_malloc(sizeof(*ctx),"sha1_init");
SHA1Init(ctx);
return ctx;
SHA1Init(ctx);
return ctx;
uint8_t digest[20];
int i;
uint8_t digest[20];
int i;
- st=safe_malloc(sizeof(*st),"sha1_module");
st->cl.description="sha1";
st->cl.type=CL_HASH;
st->cl.apply=NULL;
st->cl.description="sha1";
st->cl.type=CL_HASH;
st->cl.apply=NULL;
- st=safe_malloc(sizeof(*st),"site_apply");
st->cl.description="site";
st->cl.type=CL_SITE;
st->cl.description="site";
st->cl.type=CL_SITE;
item_t *item;
dict_t *dict;
item_t *item;
dict_t *dict;
- st=safe_malloc(sizeof(*st),"userv_apply");
/* First parameter must be a dict */
item=list_elem(args,0);
/* First parameter must be a dict */
item=list_elem(args,0);
item_t *item;
dict_t *dict;
item_t *item;
dict_t *dict;
- st=safe_malloc(sizeof(*st),"serpent");
st->cl.description="serpent-cbc256";
st->cl.type=CL_TRANSFORM;
st->cl.apply=NULL;
st->cl.description="serpent-cbc256";
st->cl.type=CL_TRANSFORM;
st->cl.apply=NULL;
item_t *item;
dict_t *dict;
item_t *item;
dict_t *dict;
- st=safe_malloc(sizeof(*st),"eax-serpent");
st->cl.description="eax-serpent";
st->cl.type=CL_TRANSFORM;
st->cl.apply=NULL;
st->cl.description="eax-serpent";
st->cl.type=CL_TRANSFORM;
st->cl.apply=NULL;
dict_t *dict;
string_t flavour,type;
dict_t *dict;
string_t flavour,type;
- st=safe_malloc(sizeof(*st),"tun_apply");
/* First parameter must be a dict */
item=list_elem(args,0);
/* First parameter must be a dict */
item=list_elem(args,0);
- h=safe_malloc(sizeof(*h),"add_hook");
h->fn=fn;
h->state=state;
LIST_INSERT_HEAD(&hooks[phase],h,entry);
h->fn=fn;
h->state=state;
LIST_INSERT_HEAD(&hooks[phase],h,entry);
bool_t lockdown=False;
uint32_t len=DEFAULT_BUFFER_SIZE;
bool_t lockdown=False;
uint32_t len=DEFAULT_BUFFER_SIZE;
- st=safe_malloc(sizeof(*st),"buffer_apply");
st->cl.description="buffer";
st->cl.type=CL_BUFFER;
st->cl.apply=NULL;
st->cl.description="buffer";
st->cl.type=CL_BUFFER;
st->cl.apply=NULL;