diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2015-03-21 13:42:12 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2015-04-21 16:57:08 -0700 |
commit | 1c56ac63c040280498c4a9d67b48c35b60070821 (patch) | |
tree | ab1073d348cb1acf0523ede3e1f2fa73f3b5fdb6 /Xi | |
parent | b9e665c8b2f048feb3064ce412e0b3e9eb6797b0 (diff) |
Convert top level extensions to new *allocarray functions
v2: remove now useless parentheses
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Diffstat (limited to 'Xi')
-rw-r--r-- | Xi/exevents.c | 6 | ||||
-rw-r--r-- | Xi/getprop.c | 2 | ||||
-rw-r--r-- | Xi/xiproperty.c | 8 |
3 files changed, 7 insertions, 9 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c index 0857bcee6..1c586d051 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -471,9 +471,9 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to) oldTrace = to->focus->trace; memcpy(to->focus, from->focus, sizeof(FocusClassRec)); - to->focus->trace = realloc(oldTrace, - to->focus->traceSize * - sizeof(WindowPtr)); + to->focus->trace = reallocarray(oldTrace, + to->focus->traceSize, + sizeof(WindowPtr)); if (!to->focus->trace && to->focus->traceSize) FatalError("[Xi] no memory for trace.\n"); memcpy(to->focus->trace, from->focus->trace, diff --git a/Xi/getprop.c b/Xi/getprop.c index 4d6ce6338..19f18af21 100644 --- a/Xi/getprop.c +++ b/Xi/getprop.c @@ -118,7 +118,7 @@ ProcXGetDeviceDontPropagateList(ClientPtr client) ClassFromMask(NULL, others->dontPropagateMask[i], i, &count, COUNT); if (count) { rep.count = count; - buf = (XEventClass *) malloc(rep.count * sizeof(XEventClass)); + buf = xallocarray(rep.count, sizeof(XEventClass)); rep.length = bytes_to_int32(rep.count * sizeof(XEventClass)); tbuf = buf; diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c index 8e8e4b061..e3b8f5abe 100644 --- a/Xi/xiproperty.c +++ b/Xi/xiproperty.c @@ -221,7 +221,7 @@ list_atoms(DeviceIntPtr dev, int *natoms, Atom **atoms_return) if (nprops) { Atom *a; - atoms = malloc(nprops * sizeof(Atom)); + atoms = xallocarray(nprops, sizeof(Atom)); if (!atoms) return BadAlloc; a = atoms; @@ -687,7 +687,6 @@ XIChangeDeviceProperty(DeviceIntPtr dev, Atom property, Atom type, { XIPropertyPtr prop; int size_in_bytes; - int total_size; unsigned long total_len; XIPropertyValuePtr prop_value; XIPropertyValueRec new_value; @@ -725,9 +724,8 @@ XIChangeDeviceProperty(DeviceIntPtr dev, Atom property, Atom type, if (mode == PropModeReplace || len > 0) { void *new_data = NULL, *old_data = NULL; - total_size = total_len * size_in_bytes; - new_value.data = (void *) malloc(total_size); - if (!new_value.data && total_size) { + new_value.data = xallocarray(total_len, size_in_bytes); + if (!new_value.data && total_len && size_in_bytes) { if (add) XIDestroyDeviceProperty(prop); return BadAlloc; |