os: 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
d819be0df9
commit
a51511635c
|
@ -118,6 +118,8 @@ SOFTWARE.
|
|||
#include "probes.h"
|
||||
#include "xdmcp.h"
|
||||
|
||||
#define MAX_CONNECTIONS (1 << 16)
|
||||
|
||||
struct ospoll *server_poll;
|
||||
|
||||
Bool NewOutputPending; /* not yet attempted to write some new output */
|
||||
|
@ -265,7 +267,12 @@ CreateWellKnownSockets(void)
|
|||
LogSetDisplay();
|
||||
}
|
||||
|
||||
ListenTransFds = xallocarray(ListenTransCount, sizeof (int));
|
||||
if (ListenTransCount >= MAX_CONNECTIONS) {
|
||||
FatalError ("Tried to clear too many listening sockets - OOM");
|
||||
return; // mostly to keep GCC from complaining about too large alloc
|
||||
}
|
||||
|
||||
ListenTransFds = calloc(ListenTransCount, sizeof(int));
|
||||
if (ListenTransFds == NULL)
|
||||
FatalError ("Failed to create listening socket array");
|
||||
|
||||
|
|
Loading…
Reference in New Issue