xwayland: replace xallocarray() by calloc()
Only key difference that calloc(), in contrast to rellocarray(), is zero-initializing. The overhead is hard to measure on today's machines, and it's safer programming practise to always allocate zero-initialized, so one can't forget to do it explicitly. Cocci rule: @@ expression COUNT; expression LEN; @@ - xallocarray(COUNT,LEN) + calloc(COUNT,LEN) Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
d38514d2a2
commit
b596d329ec
|
@ -242,7 +242,7 @@ xwl_get_rrmodes_from_connector_id(int drm, int32_t connector_id, int *nmode, int
|
|||
ErrorF("drmModeGetConnector for connector %d failed\n", connector_id);
|
||||
return NULL;
|
||||
}
|
||||
rrmodes = xallocarray(conn->count_modes, sizeof(RRModePtr));
|
||||
rrmodes = calloc(conn->count_modes, sizeof(RRModePtr));
|
||||
if (!rrmodes) {
|
||||
ErrorF("Failed to allocate connector modes\n");
|
||||
drmModeFreeConnector(conn);
|
||||
|
|
|
@ -359,7 +359,8 @@ output_get_rr_modes(struct xwl_output *xwl_output,
|
|||
RRModePtr *rr_modes;
|
||||
int i;
|
||||
|
||||
rr_modes = xallocarray(ARRAY_SIZE(xwl_output_fake_modes) + 1, sizeof(RRModePtr));
|
||||
rr_modes = calloc(ARRAY_SIZE(xwl_output_fake_modes) + 1,
|
||||
sizeof(RRModePtr));
|
||||
if (!rr_modes)
|
||||
goto err;
|
||||
|
||||
|
@ -1230,7 +1231,7 @@ xwl_randr_add_modes_fixed(struct xwl_output *xwl_output,
|
|||
RRModePtr mode;
|
||||
int i, nmodes, current;
|
||||
|
||||
modes = xallocarray(ARRAY_SIZE(xwl_output_fake_modes) + 1, sizeof(RRModePtr));
|
||||
modes = calloc(ARRAY_SIZE(xwl_output_fake_modes) + 1, sizeof(RRModePtr));
|
||||
if (!modes) {
|
||||
ErrorF("Failed to allocated RandR modes\n");
|
||||
return FALSE;
|
||||
|
|
Loading…
Reference in New Issue