diff options
author | Seung-Woo Kim <sw0312.kim@samsung.com> | 2017-07-03 16:45:51 +0900 |
---|---|---|
committer | Seung-Woo Kim <sw0312.kim@samsung.com> | 2019-03-15 18:32:18 +0900 |
commit | d2ebfa36252f1869f9cc5362507937c4205a453e (patch) | |
tree | d9098ecce598fbbf7ab8704c600da33c56fd050b | |
parent | 0b249d13debb83030c45e5793683f09a7ba7b195 (diff) | |
download | libdrm-d2ebfa36252f1869f9cc5362507937c4205a453e.tar.gz libdrm-d2ebfa36252f1869f9cc5362507937c4205a453e.tar.bz2 libdrm-d2ebfa36252f1869f9cc5362507937c4205a453e.zip |
ipptest: replace malloc + memset with calloc
It is not required to call two functions, so instead, this patch
fixes to use calloc.
Change-Id: Ib7ebee24152c7b41a0b936cb3085aa675de82c0b
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
-rw-r--r-- | tests/ipptest/fimc.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/tests/ipptest/fimc.c b/tests/ipptest/fimc.c index 70f6fa51..c31e578f 100644 --- a/tests/ipptest/fimc.c +++ b/tests/ipptest/fimc.c @@ -96,31 +96,24 @@ struct resources *get_resources(struct device *dev) struct resources *res; int i; - res = malloc(sizeof *res); + res = calloc(1, sizeof(*res)); if (res == 0) return NULL; - memset(res, 0, sizeof *res); - res->res = drmModeGetResources(dev->fd); if (!res->res) { fprintf(stderr, "drmModeGetResources failed: %d\n", errno); goto error; } - res->crtcs = malloc(res->res->count_crtcs * sizeof *res->crtcs); - res->encoders = malloc(res->res->count_encoders * sizeof *res->encoders); - res->connectors = malloc(res->res->count_connectors * sizeof *res->connectors); - res->fbs = malloc(res->res->count_fbs * sizeof *res->fbs); + res->crtcs = calloc(res->res->count_crtcs, sizeof(*res->crtcs)); + res->encoders = calloc(res->res->count_encoders, sizeof(*res->encoders)); + res->connectors = calloc(res->res->count_connectors, sizeof(*res->connectors)); + res->fbs = calloc(res->res->count_fbs, sizeof(*res->fbs)); if (!res->crtcs || !res->encoders || !res->connectors || !res->fbs) goto error; - memset(res->crtcs , 0, res->res->count_crtcs * sizeof *res->crtcs); - memset(res->encoders, 0, res->res->count_encoders * sizeof *res->encoders); - memset(res->connectors, 0, res->res->count_connectors * sizeof *res->connectors); - memset(res->fbs, 0, res->res->count_fbs * sizeof *res->fbs); - #define get_resource(_res, __res, type, Type) \ do { \ int i; \ @@ -207,12 +200,10 @@ struct resources *get_resources(struct device *dev) return res; } - res->planes = malloc(res->plane_res->count_planes * sizeof *res->planes); + res->planes = calloc(res->plane_res->count_planes, sizeof(*res->planes)); if (!res->planes) goto error; - memset(res->planes, 0, res->plane_res->count_planes * sizeof *res->planes); - get_resource(res, plane_res, plane, Plane); get_properties(res, plane_res, plane, PLANE); @@ -354,7 +345,7 @@ static int pipe_find_crtc_and_mode(struct device *dev, struct pipe_arg *pipe, /* Count the number of connectors and allocate them. */ pipe->num_cons = 1; - pipe->con_ids = malloc(pipe->num_cons * sizeof(*pipe->con_ids)); + pipe->con_ids = calloc(pipe->num_cons, sizeof(*pipe->con_ids)); if (!pipe->con_ids) return -1; |