{
struct extent_buffer *eb;
- eb = malloc(sizeof(struct extent_buffer) + size);
+ eb = calloc(1, sizeof(struct extent_buffer) + size);
if (!eb)
return NULL;
- memset(eb, 0, sizeof(struct extent_buffer) + size);
eb->start = bytenr;
eb->len = size;
size = sizeof(struct btrfs_list_comparer_set) +
BTRFS_LIST_NCOMPS_INCREASE * sizeof(struct btrfs_list_comparer);
- set = malloc(size);
+ set = calloc(1, size);
if (!set) {
fprintf(stderr, "memory allocation failed\n");
exit(1);
}
- memset(set, 0, size);
set->total = BTRFS_LIST_NCOMPS_INCREASE;
return set;
if (!ret)
return 0;
- ri = malloc(sizeof(*ri));
+ ri = calloc(1, sizeof(*ri));
if (!ri) {
printf("memory allocation failed\n");
exit(1);
}
- memset(ri, 0, sizeof(*ri));
ri->root_id = root_id;
if (name && name_len > 0) {
size = sizeof(struct btrfs_list_filter_set) +
BTRFS_LIST_NFILTERS_INCREASE * sizeof(struct btrfs_list_filter);
- set = malloc(size);
+ set = calloc(1, size);
if (!set) {
fprintf(stderr, "memory allocation failed\n");
exit(1);
}
- memset(set, 0, size);
set->total = BTRFS_LIST_NFILTERS_INCREASE;
return set;
{
struct extent_record *rec;
- rec = malloc(sizeof(*rec));
+ rec = calloc(1, sizeof(*rec));
if (!rec) {
fprintf(stderr, "Fail to allocate memory for extent record.\n");
exit(1);
}
- memset(rec, 0, sizeof(*rec));
rec->cache.start = btrfs_header_bytenr(eb);
rec->cache.size = eb->len;
rec->generation = btrfs_header_generation(eb);
nstripes = btrfs_get_device_extents(bg->objectid,
&rc->devext.no_chunk_orphans,
&devexts);
- chunk = malloc(btrfs_chunk_record_size(nstripes));
+ chunk = calloc(1, btrfs_chunk_record_size(nstripes));
if (!chunk)
return -ENOMEM;
- memset(chunk, 0, btrfs_chunk_record_size(nstripes));
INIT_LIST_HEAD(&chunk->dextents);
chunk->bg_rec = bg;
chunk->cache.start = bg->objectid;
return backref;
}
- backref = malloc(sizeof(*backref) + namelen + 1);
- memset(backref, 0, sizeof(*backref) + namelen + 1);
+ backref = calloc(1, sizeof(*backref) + namelen + 1);
backref->ref_root = ref_root;
backref->dir = dir;
backref->index = index;
ptr = btrfs_item_ptr(leaf, slot, struct btrfs_chunk);
num_stripes = btrfs_chunk_num_stripes(leaf, ptr);
- rec = malloc(btrfs_chunk_record_size(num_stripes));
+ rec = calloc(1, btrfs_chunk_record_size(num_stripes));
if (!rec) {
fprintf(stderr, "memory allocation failed\n");
exit(-1);
}
- memset(rec, 0, btrfs_chunk_record_size(num_stripes));
-
INIT_LIST_HEAD(&rec->list);
INIT_LIST_HEAD(&rec->dextents);
rec->bg_rec = NULL;
struct btrfs_block_group_item *ptr;
struct block_group_record *rec;
- rec = malloc(sizeof(*rec));
+ rec = calloc(1, sizeof(*rec));
if (!rec) {
fprintf(stderr, "memory allocation failed\n");
exit(-1);
}
- memset(rec, 0, sizeof(*rec));
rec->cache.start = key->objectid;
rec->cache.size = key->offset;
struct device_extent_record *rec;
struct btrfs_dev_extent *ptr;
- rec = malloc(sizeof(*rec));
+ rec = calloc(1, sizeof(*rec));
if (!rec) {
fprintf(stderr, "memory allocation failed\n");
exit(-1);
}
- memset(rec, 0, sizeof(*rec));
rec->cache.objectid = key->objectid;
rec->cache.start = key->offset;
u32 blocksize;
int ret = 0;
- root = malloc(sizeof(*root));
+ root = calloc(1, sizeof(*root));
if (!root)
return ERR_PTR(-ENOMEM);
- memset(root, 0, sizeof(*root));
if (location->offset == (u64)-1) {
ret = find_and_setup_root(tree_root, fs_info,
location->objectid, root);
{
struct btrfs_fs_info *fs_info;
- fs_info = malloc(sizeof(struct btrfs_fs_info));
+ fs_info = calloc(1, sizeof(struct btrfs_fs_info));
if (!fs_info)
return NULL;
- memset(fs_info, 0, sizeof(struct btrfs_fs_info));
-
fs_info->tree_root = calloc(1, sizeof(struct btrfs_root));
fs_info->extent_root = calloc(1, sizeof(struct btrfs_root));
fs_info->chunk_root = calloc(1, sizeof(struct btrfs_root));
{
struct extent_buffer *eb;
- eb = malloc(sizeof(struct extent_buffer) + blocksize);
+ eb = calloc(1, sizeof(struct extent_buffer) + blocksize);
if (!eb) {
BUG();
return NULL;
}
- memset(eb, 0, sizeof(struct extent_buffer) + blocksize);
eb->start = bytenr;
eb->len = blocksize;
* do our IO in extent buffers so it can work
* against any raid type
*/
- eb = malloc(sizeof(*eb) + sectorsize);
+ eb = calloc(1, sizeof(*eb) + sectorsize);
if (!eb) {
ret = -ENOMEM;
goto end;
}
- memset(eb, 0, sizeof(*eb) + sectorsize);
again:
size = sizeof(struct btrfs_qgroup_comparer_set) +
BTRFS_QGROUP_NCOMPS_INCREASE *
sizeof(struct btrfs_qgroup_comparer);
- set = malloc(size);
+ set = calloc(1, size);
if (!set) {
fprintf(stderr, "memory allocation failed\n");
exit(1);
}
- memset(set, 0, size);
set->total = BTRFS_QGROUP_NCOMPS_INCREASE;
return set;
if (!ret)
return 0;
- bq = malloc(sizeof(*bq));
+ bq = calloc(1, sizeof(*bq));
if (!bq) {
printf("memory allocation failed\n");
exit(1);
}
- memset(bq, 0, sizeof(*bq));
if (qgroupid) {
bq->qgroupid = qgroupid;
INIT_LIST_HEAD(&bq->qgroups);
size = sizeof(struct btrfs_qgroup_filter_set) +
BTRFS_QGROUP_NFILTERS_INCREASE *
sizeof(struct btrfs_qgroup_filter);
- set = malloc(size);
+ set = calloc(1, size);
if (!set) {
fprintf(stderr, "memory allocation failed\n");
exit(1);
}
- memset(set, 0, size);
set->total = BTRFS_QGROUP_NFILTERS_INCREASE;
return set;
struct btrfs_root *root;
struct btrfs_trans_handle *trans;
- buf = malloc(512);
- memset(buf, 0, 512);
+ buf = calloc(1, 512);
radix_tree_init();
if (raid_map[i] >= BTRFS_RAID5_P_STRIPE)
break;
- eb = malloc(sizeof(struct extent_buffer) + stripe_len);
+ eb = calloc(1, sizeof(struct extent_buffer) + stripe_len);
if (!eb)
BUG();
- memset(eb, 0, sizeof(struct extent_buffer) + stripe_len);
eb->start = raid_map[i];
eb->len = stripe_len;