]> andersk Git - moira.git/blobdiff - server/mr_util.c
punt mrgdb
[moira.git] / server / mr_util.c
index 04b528b62ffeea11a1f6aa5cb7dd58e5e3fa34a9..433f1893b4037aa8064cd8ae1d58fdf9e7192659 100644 (file)
@@ -9,6 +9,7 @@
 #include "mr_server.h"
 
 #include <ctype.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -83,8 +84,10 @@ void mr_com_err(const char *whoami, long code, const char *fmt, va_list pvar)
        fprintf(stderr, "[#%d]", cur_client->id);
       fputs(": ", stderr);
     }
-  if (code)
+  if (code) {
     fputs(error_message(code), stderr);
+    fputs(" ", stderr);
+  }
   if (fmt)
     vfprintf(stderr, fmt, pvar);
   putc('\n', stderr);
@@ -145,3 +148,27 @@ char **mr_copy_args(char **argv, int argc)
     a[i] = strdup(argv[i]);
   return a;
 }
+
+
+/* malloc or die! */
+void *xmalloc(size_t bytes)
+{
+  void *buf = malloc(bytes);
+
+  if (buf)
+    return buf;
+
+  critical_alert("moirad", "Out of memory");
+  exit(1);
+}
+
+void *xrealloc(void *ptr, size_t bytes)
+{
+  void *buf = realloc(ptr, bytes);
+
+  if (buf)
+    return buf;
+
+  critical_alert("moirad", "Out of memory");
+  exit(1);
+}
This page took 0.122999 seconds and 4 git commands to generate.