/*
- * Copyright (c) 1999-2005, 2007, 2010-2011
+ * Copyright (c) 1999-2005, 2007, 2010-2013
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
#include <config.h>
#include <sys/types.h>
-#include <sys/param.h>
#include <stdio.h>
#ifdef STDC_HEADERS
# include <stdlib.h>
#include "missing.h"
#include "alloc.h"
#include "error.h"
+#include "errno.h"
#define DEFAULT_TEXT_DOMAIN "sudo"
#include "gettext.h"
void *ptr;
if (size == 0)
- errorx2(1, _("internal error, tried to emalloc(0)"));
+ fatalx_nodebug(_("internal error, tried to emalloc(0)"));
if ((ptr = malloc(size)) == NULL)
- errorx2(1, _("unable to allocate memory"));
+ fatalx_nodebug(NULL);
return ptr;
}
void *ptr;
if (nmemb == 0 || size == 0)
- errorx2(1, _("internal error, tried to emalloc2(0)"));
+ fatalx_nodebug(_("internal error, tried to emalloc2(0)"));
if (nmemb > SIZE_MAX / size)
- errorx2(1, _("internal error, %s overflow"), "emalloc2()");
+ fatalx_nodebug(_("internal error, %s overflow"), "emalloc2()");
size *= nmemb;
if ((ptr = malloc(size)) == NULL)
- errorx2(1, _("unable to allocate memory"));
+ fatalx_nodebug(NULL);
return ptr;
}
void *ptr;
if (nmemb == 0 || size == 0)
- errorx2(1, _("internal error, tried to ecalloc(0)"));
+ fatalx_nodebug(_("internal error, tried to ecalloc(0)"));
if (nmemb != 1) {
if (nmemb > SIZE_MAX / size)
- errorx2(1, _("internal error, %s overflow"), "ecalloc()");
+ fatalx_nodebug(_("internal error, %s overflow"), "ecalloc()");
size *= nmemb;
}
if ((ptr = malloc(size)) == NULL)
- errorx2(1, _("unable to allocate memory"));
+ fatalx_nodebug(NULL);
memset(ptr, 0, size);
return ptr;
}
{
if (size == 0)
- errorx2(1, _("internal error, tried to erealloc(0)"));
+ fatalx_nodebug(_("internal error, tried to erealloc(0)"));
ptr = ptr ? realloc(ptr, size) : malloc(size);
if (ptr == NULL)
- errorx2(1, _("unable to allocate memory"));
+ fatalx_nodebug(NULL);
return ptr;
}
{
if (nmemb == 0 || size == 0)
- errorx2(1, _("internal error, tried to erealloc3(0)"));
+ fatalx_nodebug(_("internal error, tried to erealloc3(0)"));
if (nmemb > SIZE_MAX / size)
- errorx2(1, _("internal error, %s overflow"), "erealloc3()");
+ fatalx_nodebug(_("internal error, %s overflow"), "erealloc3()");
size *= nmemb;
ptr = ptr ? realloc(ptr, size) : malloc(size);
if (ptr == NULL)
- errorx2(1, _("unable to allocate memory"));
+ fatalx_nodebug(NULL);
return ptr;
}
size_t size;
if (nmemb == 0 || msize == 0)
- errorx2(1, _("internal error, tried to erecalloc(0)"));
+ fatalx_nodebug(_("internal error, tried to erecalloc(0)"));
if (nmemb > SIZE_MAX / msize)
- errorx2(1, _("internal error, %s overflow"), "erecalloc()");
+ fatalx_nodebug(_("internal error, %s overflow"), "erecalloc()");
size = nmemb * msize;
ptr = ptr ? realloc(ptr, size) : malloc(size);
if (ptr == NULL)
- errorx2(1, _("unable to allocate memory"));
+ fatalx_nodebug(NULL);
if (nmemb > onmemb) {
size = (nmemb - onmemb) * msize;
memset((char *)ptr + (onmemb * msize), 0, size);
{
int len;
va_list ap;
+
va_start(ap, fmt);
len = vasprintf(ret, fmt, ap);
va_end(ap);
if (len == -1)
- errorx2(1, _("unable to allocate memory"));
+ fatalx_nodebug(NULL);
return len;
}
int len;
if ((len = vasprintf(ret, format, args)) == -1)
- errorx2(1, _("unable to allocate memory"));
+ fatalx_nodebug(NULL);
return len;
}
-
-/*
- * Wrapper for free(3) so we can depend on C89 semantics.
- */
-void
-efree(void *ptr)
-{
- if (ptr != NULL)
- free(ptr);
-}