if (!f)
return log_error_errno(-1, errno, "Failed to popen() %s", buffer);
- output = malloc(LXC_LOG_BUFFER_SIZE);
+ output = zalloc(LXC_LOG_BUFFER_SIZE);
if (!output)
return log_error_errno(-1, ENOMEM, "Failed to allocate memory for %s", buffer);
return -EFBIG;
}
- buffer = malloc(size);
+ buffer = zalloc(size);
if (!buffer)
return -ENOMEM;
size_t size;
if (!*pp) {
- *pp = malloc(strlen(name) + strlen("container_ttys=") + 1);
+ *pp = zalloc(strlen(name) + strlen("container_ttys=") + 1);
if (!*pp)
return false;
int i;
struct lxc_conf *new;
- new = malloc(sizeof(*new));
+ new = zalloc(sizeof(*new));
if (!new)
return NULL;
- memset(new, 0, sizeof(*new));
new->loglevel = LXC_LOG_LEVEL_NOTSET;
new->personality = -1;
if (!map)
return NULL;
- retmap = malloc(sizeof(*retmap));
+ retmap = zalloc(sizeof(*retmap));
if (!retmap)
return NULL;
int hostid_mapped;
struct id_map *tmp = NULL;
- entry = malloc(sizeof(*entry));
+ entry = zalloc(sizeof(*entry));
if (!entry)
return NULL;
return log_debug(NULL, "Failed to find mapping for gid %d", egid);
/* Allocate new {g,u}id map list. */
- idmap = malloc(sizeof(*idmap));
+ idmap = lxc_list_new();
if (!idmap)
return NULL;
- lxc_list_init(idmap);
/* Add container root to the map. */
- tmplist = malloc(sizeof(*tmplist));
+ tmplist = lxc_list_new();
if (!tmplist)
return NULL;
/* idmap will now keep track of that memory. */
if (container_root_uid) {
/* Add container root to the map. */
- tmplist = malloc(sizeof(*tmplist));
+ tmplist = lxc_list_new();
if (!tmplist)
return NULL;
/* idmap will now keep track of that memory. */
lxc_list_add_tail(idmap, tmplist);
}
- tmplist = malloc(sizeof(*tmplist));
+ tmplist = lxc_list_new();
if (!tmplist)
return NULL;
/* idmap will now keep track of that memory. */
lxc_list_add_tail(idmap, tmplist);
if (container_root_gid) {
- tmplist = malloc(sizeof(*tmplist));
+ tmplist = lxc_list_new();
if (!tmplist)
return NULL;
/* idmap will now keep track of that memory. */
egid = getegid();
/* Allocate new {g,u}id map list. */
- idmap = malloc(sizeof(*idmap));
+ idmap = lxc_list_new();
if (!idmap)
goto on_error;
- lxc_list_init(idmap);
/* Find container root. */
lxc_list_for_each (cur, &conf->id_map) {
struct id_map *tmpmap;
- tmplist = malloc(sizeof(*tmplist));
+ tmplist = lxc_list_new();
if (!tmplist)
goto on_error;
- tmpmap = malloc(sizeof(*tmpmap));
+ tmpmap = zalloc(sizeof(*tmpmap));
if (!tmpmap) {
free(tmplist);
goto on_error;
if (host_uid_map && (host_uid_map != container_root_uid)) {
/* Add container root to the map. */
- tmplist = malloc(sizeof(*tmplist));
+ tmplist = lxc_list_new();
if (!tmplist)
goto on_error;
lxc_list_add_elem(tmplist, host_uid_map);
host_uid_map = NULL;
if (host_gid_map && (host_gid_map != container_root_gid)) {
- tmplist = malloc(sizeof(*tmplist));
+ tmplist = lxc_list_new();
if (!tmplist)
goto on_error;
lxc_list_add_elem(tmplist, host_gid_map);
TRACE("Chowned %d(%s) to -1:%d", target_fd, path, hostgid);
}
- idmap = malloc(sizeof(*idmap));
+ idmap = lxc_list_new();
if (!idmap)
return -ENOMEM;
- lxc_list_init(idmap);
/* "u:0:rootuid:1" */
ret = add_idmap_entry(idmap, ID_TYPE_UID, 0, container_host_uid, 1);
if (bufsize == -1)
bufsize = 1024;
- buf = malloc(bufsize);
+ buf = zalloc(bufsize);
if (!buf)
return NULL;
if (bufsize == -1)
bufsize = 1024;
- buf = malloc(bufsize);
+ buf = zalloc(bufsize);
if (!buf)
return NULL;
struct lxc_cgroup *cg = NULL;
struct lxc_list *it = NULL, *item = NULL, *memsw_limit = NULL;
- result = malloc(sizeof(*result));
+ result = lxc_list_new();
if (!result)
return NULL;
lxc_list_init(result);
/* Iterate over the cgroup settings and copy them to the output list. */
lxc_list_for_each (it, cgroup_settings) {
- item = malloc(sizeof(*item));
+ item = zalloc(sizeof(*item));
if (!item) {
free_cgroup_settings(result);
return NULL;