@matheusbsbs / matheus-bagliano / commits / 1b4713fb9e
Fork 0

Use xmalloc/xcalloc

H. Peter Anvin committed Sep 30, 2005 at 10:47 UTC 1b4713fb9e6ec614e8dbca90b1a57d5ffa2f3fde
1 file changed +2 -6
daemon.c
+2 -6
@@ -463,9 +463,7 @@ static int socksetup(int port, int **socklist_p)
463 return 0;
464 }
465
466 - *socklist_p = malloc(sizeof(int));
467 - if ( !*socklist_p )
468 - die("memory allocation failed: %s", strerror(errno));
466 + *socklist_p = xmalloc(sizeof(int));
467 **socklist_p = sockfd;
468 }
469
@@ -476,9 +474,7 @@ static int service_loop(int socknum, int *socklist)
474 struct pollfd *pfd;
475 int i;
476
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));
478
479 for (i = 0; i < socknum; i++) {
480 pfd[i].fd = socklist[i];