Convert os/* 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>
This commit is contained in:
parent
ae75d50395
commit
df4e41fdb4
|
@ -309,7 +309,7 @@ InitConnectionLimits(void)
|
||||||
|
|
||||||
#if !defined(WIN32)
|
#if !defined(WIN32)
|
||||||
if (!ConnectionTranslation)
|
if (!ConnectionTranslation)
|
||||||
ConnectionTranslation = (int *) xnfalloc(sizeof(int) * (lastfdesc + 1));
|
ConnectionTranslation = xnfallocarray(lastfdesc + 1, sizeof(int));
|
||||||
#else
|
#else
|
||||||
InitConnectionTranslation();
|
InitConnectionTranslation();
|
||||||
#endif
|
#endif
|
||||||
|
@ -429,7 +429,9 @@ CreateWellKnownSockets(void)
|
||||||
display = dynamic_display;
|
display = dynamic_display;
|
||||||
}
|
}
|
||||||
|
|
||||||
ListenTransFds = malloc(ListenTransCount * sizeof (int));
|
ListenTransFds = xallocarray(ListenTransCount, sizeof (int));
|
||||||
|
if (ListenTransFds == NULL)
|
||||||
|
FatalError ("Failed to create listening socket array");
|
||||||
|
|
||||||
for (i = 0; i < ListenTransCount; i++) {
|
for (i = 0; i < ListenTransCount; i++) {
|
||||||
int fd = _XSERVTransGetConnectionNumber(ListenTransConns[i]);
|
int fd = _XSERVTransGetConnectionNumber(ListenTransConns[i]);
|
||||||
|
@ -1291,11 +1293,10 @@ ListenOnOpenFD(int fd, int noxauth)
|
||||||
|
|
||||||
/* Allocate space to store it */
|
/* Allocate space to store it */
|
||||||
ListenTransFds =
|
ListenTransFds =
|
||||||
(int *) realloc(ListenTransFds, (ListenTransCount + 1) * sizeof(int));
|
xnfreallocarray(ListenTransFds, ListenTransCount + 1, sizeof(int));
|
||||||
ListenTransConns =
|
ListenTransConns =
|
||||||
(XtransConnInfo *) realloc(ListenTransConns,
|
xnfreallocarray(ListenTransConns, ListenTransCount + 1,
|
||||||
(ListenTransCount +
|
sizeof(XtransConnInfo));
|
||||||
1) * sizeof(XtransConnInfo));
|
|
||||||
|
|
||||||
/* Store it */
|
/* Store it */
|
||||||
ListenTransConns[ListenTransCount] = ciptr;
|
ListenTransConns[ListenTransCount] = ciptr;
|
||||||
|
|
|
@ -2001,7 +2001,7 @@ xstrtokenize(const char *str, const char *separators)
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
goto error;
|
goto error;
|
||||||
for (tok = strtok(tmp, separators); tok; tok = strtok(NULL, separators)) {
|
for (tok = strtok(tmp, separators); tok; tok = strtok(NULL, separators)) {
|
||||||
nlist = realloc(list, (num + 2) * sizeof(*list));
|
nlist = reallocarray(list, num + 2, sizeof(*list));
|
||||||
if (!nlist)
|
if (!nlist)
|
||||||
goto error;
|
goto error;
|
||||||
list = nlist;
|
list = nlist;
|
||||||
|
|
Loading…
Reference in New Issue