Skip to content

Commit 1b4713f

Browse files
author
H. Peter Anvin
committed
Use xmalloc/xcalloc
1 parent d6b89e7 commit 1b4713f

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

daemon.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,7 @@ static int socksetup(int port, int **socklist_p)
463463
return 0;
464464
}
465465

466-
*socklist_p = malloc(sizeof(int));
467-
if ( !*socklist_p )
468-
die("memory allocation failed: %s", strerror(errno));
466+
*socklist_p = xmalloc(sizeof(int));
469467
**socklist_p = sockfd;
470468
}
471469

@@ -476,9 +474,7 @@ static int service_loop(int socknum, int *socklist)
476474
struct pollfd *pfd;
477475
int i;
478476

479-
pfd = calloc(socknum, sizeof(struct pollfd));
480-
if (!pfd)
481-
die("memory allocation failed: %s", strerror(errno));
477+
pfd = xcalloc(socknum, sizeof(struct pollfd));
482478

483479
for (i = 0; i < socknum; i++) {
484480
pfd[i].fd = socklist[i];

0 commit comments

Comments
 (0)