xi: 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
01d6efb414
commit
a222349c43
|
@ -116,7 +116,7 @@ ProcXGetDeviceDontPropagateList(ClientPtr client)
|
|||
ClassFromMask(NULL, others->dontPropagateMask[i], i, &count, COUNT);
|
||||
if (count) {
|
||||
rep.count = count;
|
||||
buf = xallocarray(rep.count, sizeof(XEventClass));
|
||||
buf = calloc(rep.count, sizeof(XEventClass));
|
||||
rep.length = bytes_to_int32(rep.count * sizeof(XEventClass));
|
||||
|
||||
tbuf = buf;
|
||||
|
|
|
@ -222,7 +222,7 @@ list_atoms(DeviceIntPtr dev, int *natoms, Atom **atoms_return)
|
|||
if (nprops) {
|
||||
Atom *a;
|
||||
|
||||
atoms = xallocarray(nprops, sizeof(Atom));
|
||||
atoms = calloc(nprops, sizeof(Atom));
|
||||
if (!atoms)
|
||||
return BadAlloc;
|
||||
a = atoms;
|
||||
|
@ -723,7 +723,7 @@ XIChangeDeviceProperty(DeviceIntPtr dev, Atom property, Atom type,
|
|||
if (mode == PropModeReplace || len > 0) {
|
||||
void *new_data = NULL, *old_data = NULL;
|
||||
|
||||
new_value.data = xallocarray(total_len, size_in_bytes);
|
||||
new_value.data = calloc(total_len, size_in_bytes);
|
||||
if (!new_value.data && total_len && size_in_bytes) {
|
||||
if (add)
|
||||
XIDestroyDeviceProperty(prop);
|
||||
|
|
Loading…
Reference in New Issue