lib: Use g_malloc0 instead of g_malloc+memset

This commit is contained in:
Bastien Nocera 2013-06-26 14:21:33 +02:00
parent 6d65bfcf80
commit f3dd55815e
2 changed files with 2 additions and 4 deletions

View file

@ -97,9 +97,8 @@ static const char *finger_num_to_str(enum fp_finger finger)
static struct fp_print_data *print_data_new(uint16_t driver_id,
uint32_t devtype, enum fp_print_data_type type, size_t length)
{
struct fp_print_data *data = g_malloc(sizeof(*data) + length);
struct fp_print_data *data = g_malloc0(sizeof(*data) + length);
fp_dbg("length=%zd driver=%02x devtype=%04x", length, driver_id, devtype);
memset(data, 0, sizeof(*data));
data->driver_id = driver_id;
data->devtype = devtype;
data->type = type;

View file

@ -47,8 +47,7 @@
struct fp_img *fpi_img_new(size_t length)
{
struct fp_img *img = g_malloc(sizeof(*img) + length);
memset(img, 0, sizeof(*img));
struct fp_img *img = g_malloc0(sizeof(*img) + length);
fp_dbg("length=%zd", length);
img->length = length;
return img;