Some places forget to use zalloc().
#include "link_mon.h"
#include "local.h"
#include "lib/mm/xlate.h"
+#include "base/memory/zalloc.h"
/* FIXME: remove this and the code */
#define CMIRROR_HAS_CHECKPOINT 0
return NULL;
}
- new = malloc(sizeof(*new));
+ new = zalloc(sizeof(*new));
if (!new) {
LOG_ERROR("Unable to create checkpoint data for %u",
cp_requester);
return NULL;
}
- memset(new, 0, sizeof(*new));
new->requester = cp_requester;
strncpy(new->uuid, entry->name.value, entry->name.length);
rq_size += RECOVERING_REGION_SECTION_SIZE;
rq_size += cp->bitmap_size * 2; /* clean|sync_bits */
- rq = malloc(rq_size);
+ rq = zalloc(rq_size);
if (!rq) {
LOG_ERROR("export_checkpoint: "
"Unable to allocate transfer structs");
return -ENOMEM;
}
- memset(rq, 0, rq_size);
dm_list_init(&rq->u.list);
rq->u_rq.request_type = DM_ULOG_CHECKPOINT_READY;
return -EEXIST;
}
- new = malloc(sizeof(*new));
+ new = zalloc(sizeof(*new));
if (!new) {
LOG_ERROR("Unable to allocate memory for clog_cpg");
return -ENOMEM;
}
- memset(new, 0, sizeof(*new));
dm_list_init(&new->list);
new->lowest_id = 0xDEAD;
dm_list_init(&new->startup_list);
{
struct lockspace *ls;
- if (!(ls = malloc(sizeof(struct lockspace)))) {
+ if (!(ls = zalloc(sizeof(struct lockspace)))) {
log_error("out of memory for lockspace");
return NULL;
}
- memset(ls, 0, sizeof(struct lockspace));
INIT_LIST_HEAD(&ls->actions);
INIT_LIST_HEAD(&ls->resources);
pthread_mutex_init(&ls->mutex, NULL);
int rv;
if (r->type == LD_RT_GL || r->type == LD_RT_VG) {
- buf = malloc(sizeof(struct val_blk) + DLM_LVB_LEN);
+ buf = zalloc(sizeof(struct val_blk) + DLM_LVB_LEN);
if (!buf)
return -ENOMEM;
- memset(buf, 0, sizeof(struct val_blk) + DLM_LVB_LEN);
rdd->vb = (struct val_blk *)buf;
rdd->lksb.sb_lvbptr = buf + sizeof(struct val_blk);
goto fail;
}
- lms = malloc(sizeof(struct lm_sanlock));
+ lms = zalloc(sizeof(struct lm_sanlock));
if (!lms) {
ret = -ENOMEM;
goto fail;
memset(lsname, 0, sizeof(lsname));
strncpy(lsname, ls->name, SANLK_NAME_LEN);
- memset(lms, 0, sizeof(struct lm_sanlock));
memcpy(lms->ss.name, lsname, SANLK_NAME_LEN);
lms->ss.host_id_disk.offset = 0;
lms->ss.host_id = ls->host_id;
/* LD_RT_LV offset is set in each lm_lock call from lv_args. */
if (r->type == LD_RT_GL || r->type == LD_RT_VG) {
- rds->vb = malloc(sizeof(struct val_blk));
+ rds->vb = zalloc(sizeof(struct val_blk));
if (!rds->vb)
return -ENOMEM;
- memset(rds->vb, 0, sizeof(struct val_blk));
}
return 0;