Imported Upstream version 1.8.2
[debian/sudo] / common / alloc.c
index 7fbf3c88d3dc8b665ccd886fdef13676538d96f4..d3a251657c2186796b9d32bf1f3aac99fd612318 100644 (file)
@@ -52,6 +52,9 @@
 #include "alloc.h"
 #include "error.h"
 
+#define DEFAULT_TEXT_DOMAIN    "sudo"
+#include "gettext.h"
+
 /*
  * If there is no SIZE_MAX or SIZE_T_MAX we have to assume that size_t
  * could be signed (as it is on SunOS 4.x).  This just means that
@@ -76,10 +79,10 @@ emalloc(size_t size)
     void *ptr;
 
     if (size == 0)
-       errorx(1, "internal error, tried to emalloc(0)");
+       errorx(1, _("internal error, tried to emalloc(0)"));
 
     if ((ptr = malloc(size)) == NULL)
-       errorx(1, "unable to allocate memory");
+       errorx(1, _("unable to allocate memory"));
     return ptr;
 }
 
@@ -93,13 +96,13 @@ emalloc2(size_t nmemb, size_t size)
     void *ptr;
 
     if (nmemb == 0 || size == 0)
-       errorx(1, "internal error, tried to emalloc2(0)");
+       errorx(1, _("internal error, tried to emalloc2(0)"));
     if (nmemb > SIZE_MAX / size)
-       errorx(1, "internal error, emalloc2() overflow");
+       errorx(1, _("internal error, emalloc2() overflow"));
 
     size *= nmemb;
     if ((ptr = malloc(size)) == NULL)
-       errorx(1, "unable to allocate memory");
+       errorx(1, _("unable to allocate memory"));
     return ptr;
 }
 
@@ -113,11 +116,11 @@ erealloc(void *ptr, size_t size)
 {
 
     if (size == 0)
-       errorx(1, "internal error, tried to erealloc(0)");
+       errorx(1, _("internal error, tried to erealloc(0)"));
 
     ptr = ptr ? realloc(ptr, size) : malloc(size);
     if (ptr == NULL)
-       errorx(1, "unable to allocate memory");
+       errorx(1, _("unable to allocate memory"));
     return ptr;
 }
 
@@ -132,14 +135,14 @@ erealloc3(void *ptr, size_t nmemb, size_t size)
 {
 
     if (nmemb == 0 || size == 0)
-       errorx(1, "internal error, tried to erealloc3(0)");
+       errorx(1, _("internal error, tried to erealloc3(0)"));
     if (nmemb > SIZE_MAX / size)
-       errorx(1, "internal error, erealloc3() overflow");
+       errorx(1, _("internal error, erealloc3() overflow"));
 
     size *= nmemb;
     ptr = ptr ? realloc(ptr, size) : malloc(size);
     if (ptr == NULL)
-       errorx(1, "unable to allocate memory");
+       errorx(1, _("unable to allocate memory"));
     return ptr;
 }
 
@@ -197,7 +200,7 @@ easprintf(char **ret, const char *fmt, ...)
     va_end(ap);
 
     if (len == -1)
-       errorx(1, "unable to allocate memory");
+       errorx(1, _("unable to allocate memory"));
     return len;
 }
 
@@ -211,7 +214,7 @@ evasprintf(char **ret, const char *format, va_list args)
     int len;
 
     if ((len = vasprintf(ret, format, args)) == -1)
-       errorx(1, "unable to allocate memory");
+       errorx(1, _("unable to allocate memory"));
     return len;
 }