(1823) 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
							
								
									a80d0488bd
								
							
						
					
					
						commit
						9fe0a77df0
					
				|  | @ -119,6 +119,8 @@ SOFTWARE. | |||
| #include "probes.h" | ||||
| #include "xdmcp.h" | ||||
| 
 | ||||
| #define MAX_CONNECTIONS (2^16) | ||||
| 
 | ||||
| struct ospoll   *server_poll; | ||||
| 
 | ||||
| Bool NewOutputPending;          /* not yet attempted to write some new output */ | ||||
|  | @ -266,7 +268,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