xkb: 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
f55e01f5d8
commit
445f83668b
|
@ -2838,7 +2838,7 @@ XkbSendCompatMap(ClientPtr client,
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
if (rep->length > 0) {
|
if (rep->length > 0) {
|
||||||
data = xallocarray(rep->length, 4);
|
data = calloc(rep->length, 4);
|
||||||
if (data) {
|
if (data) {
|
||||||
register unsigned i, bit;
|
register unsigned i, bit;
|
||||||
xkbModsWireDesc *grp;
|
xkbModsWireDesc *grp;
|
||||||
|
@ -3225,7 +3225,7 @@ XkbSendIndicatorMap(ClientPtr client,
|
||||||
if (rep->length > 0) {
|
if (rep->length > 0) {
|
||||||
CARD8 *to;
|
CARD8 *to;
|
||||||
|
|
||||||
to = map = xallocarray(rep->length, 4);
|
to = map = calloc(rep->length, 4);
|
||||||
if (map) {
|
if (map) {
|
||||||
xkbIndicatorMapWireDesc *wire = (xkbIndicatorMapWireDesc *) to;
|
xkbIndicatorMapWireDesc *wire = (xkbIndicatorMapWireDesc *) to;
|
||||||
|
|
||||||
|
@ -5037,7 +5037,7 @@ XkbSendGeometry(ClientPtr client,
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (geom != NULL) {
|
if (geom != NULL) {
|
||||||
start = desc = xallocarray(rep->length, 4);
|
start = desc = calloc(rep->length, 4);
|
||||||
if (!start)
|
if (!start)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
len = rep->length * 4;
|
len = rep->length * 4;
|
||||||
|
|
|
@ -1066,8 +1066,8 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst)
|
||||||
}
|
}
|
||||||
else if (!dtype->map_count || !dtype->map ||
|
else if (!dtype->map_count || !dtype->map ||
|
||||||
i >= dst->map->num_types) {
|
i >= dst->map->num_types) {
|
||||||
tmp = xallocarray(stype->map_count,
|
tmp = calloc(stype->map_count,
|
||||||
sizeof(XkbKTMapEntryRec));
|
sizeof(XkbKTMapEntryRec));
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
dtype->map = tmp;
|
dtype->map = tmp;
|
||||||
|
@ -1095,8 +1095,7 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst)
|
||||||
}
|
}
|
||||||
else if (!dtype->preserve || !dtype->map_count ||
|
else if (!dtype->preserve || !dtype->map_count ||
|
||||||
i >= dst->map->num_types) {
|
i >= dst->map->num_types) {
|
||||||
tmp = xallocarray(stype->map_count,
|
tmp = calloc(stype->map_count, sizeof(XkbModsRec));
|
||||||
sizeof(XkbModsRec));
|
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
dtype->preserve = tmp;
|
dtype->preserve = tmp;
|
||||||
|
@ -1606,8 +1605,8 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
|
||||||
j < sshape->num_outlines;
|
j < sshape->num_outlines;
|
||||||
j++, soutline++, doutline++) {
|
j++, soutline++, doutline++) {
|
||||||
if (soutline->num_points) {
|
if (soutline->num_points) {
|
||||||
tmp = xallocarray(soutline->num_points,
|
tmp = calloc(soutline->num_points,
|
||||||
sizeof(XkbPointRec));
|
sizeof(XkbPointRec));
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
doutline->points = tmp;
|
doutline->points = tmp;
|
||||||
|
@ -1734,7 +1733,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
|
||||||
for (j = 0, srow = ssection->rows, drow = dsection->rows;
|
for (j = 0, srow = ssection->rows, drow = dsection->rows;
|
||||||
j < ssection->num_rows; j++, srow++, drow++) {
|
j < ssection->num_rows; j++, srow++, drow++) {
|
||||||
if (srow->num_keys) {
|
if (srow->num_keys) {
|
||||||
tmp = xallocarray(srow->num_keys, sizeof(XkbKeyRec));
|
tmp = calloc(srow->num_keys, sizeof(XkbKeyRec));
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
drow->keys = tmp;
|
drow->keys = tmp;
|
||||||
|
|
Loading…
Reference in New Issue