Use xmalloc/xcalloc
[git.git] / daemon.c
index 526ac78..6298f53 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -1,6 +1,5 @@
 #include "cache.h"
 #include "pkt-line.h"
-#include <alloca.h>
 #include <signal.h>
 #include <sys/wait.h>
 #include <sys/socket.h>
@@ -59,7 +58,7 @@ static void logreport(int priority, const char *err, va_list params)
        write(2, buf, buflen);
 }
 
-void logerror(const char *err, ...)
+static void logerror(const char *err, ...)
 {
        va_list params;
        va_start(params, err);
@@ -67,7 +66,7 @@ void logerror(const char *err, ...)
        va_end(params);
 }
 
-void loginfo(const char *err, ...)
+static void loginfo(const char *err, ...)
 {
        va_list params;
        if (!verbose)
@@ -464,9 +463,7 @@ static int socksetup(int port, int **socklist_p)
                return 0;
        }
 
-       *socklist_p = malloc(sizeof(int));
-       if ( !*socklist_p )
-               die("memory allocation failed: %s", strerror(errno));
+       *socklist_p = xmalloc(sizeof(int));
        **socklist_p = sockfd;
 }
 
@@ -477,9 +474,7 @@ static int service_loop(int socknum, int *socklist)
        struct pollfd *pfd;
        int i;
 
-       pfd = calloc(socknum, sizeof(struct pollfd));
-       if (!pfd)
-               die("memory allocation failed: %s", strerror(errno));
+       pfd = xcalloc(socknum, sizeof(struct pollfd));
 
        for (i = 0; i < socknum; i++) {
                pfd[i].fd = socklist[i];