version 1.1.1.4, 2013/07/22 10:46:11
|
version 1.1.1.6, 2014/06/15 16:12:54
|
Line 46
|
Line 46
|
#ifdef HAVE_INTTYPES_H |
#ifdef HAVE_INTTYPES_H |
# include <inttypes.h> |
# include <inttypes.h> |
#endif |
#endif |
|
#include <limits.h> |
|
|
|
#define DEFAULT_TEXT_DOMAIN "sudo" |
|
#include "gettext.h" /* must be included before missing.h */ |
|
|
#include "missing.h" |
#include "missing.h" |
#include "alloc.h" |
#include "alloc.h" |
#include "error.h" | #include "fatal.h" |
#include "errno.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 |
* 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 |
* could be signed (as it is on SunOS 4.x). This just means that |
Line 82 emalloc(size_t size)
|
Line 82 emalloc(size_t size)
|
fatalx_nodebug(_("internal error, tried to emalloc(0)")); |
fatalx_nodebug(_("internal error, tried to emalloc(0)")); |
|
|
if ((ptr = malloc(size)) == NULL) |
if ((ptr = malloc(size)) == NULL) |
fatalx_nodebug(NULL); | fatal_nodebug(NULL); |
return ptr; |
return ptr; |
} |
} |
|
|
Line 102 emalloc2(size_t nmemb, size_t size)
|
Line 102 emalloc2(size_t nmemb, size_t size)
|
|
|
size *= nmemb; |
size *= nmemb; |
if ((ptr = malloc(size)) == NULL) |
if ((ptr = malloc(size)) == NULL) |
fatalx_nodebug(NULL); | fatal_nodebug(NULL); |
return ptr; |
return ptr; |
} |
} |
|
|
Line 124 ecalloc(size_t nmemb, size_t size)
|
Line 124 ecalloc(size_t nmemb, size_t size)
|
size *= nmemb; |
size *= nmemb; |
} |
} |
if ((ptr = malloc(size)) == NULL) |
if ((ptr = malloc(size)) == NULL) |
fatalx_nodebug(NULL); | fatal_nodebug(NULL); |
memset(ptr, 0, size); |
memset(ptr, 0, size); |
return ptr; |
return ptr; |
} |
} |
Line 143 erealloc(void *ptr, size_t size)
|
Line 143 erealloc(void *ptr, size_t size)
|
|
|
ptr = ptr ? realloc(ptr, size) : malloc(size); |
ptr = ptr ? realloc(ptr, size) : malloc(size); |
if (ptr == NULL) |
if (ptr == NULL) |
fatalx_nodebug(NULL); | fatal_nodebug(NULL); |
return ptr; |
return ptr; |
} |
} |
|
|
Line 165 erealloc3(void *ptr, size_t nmemb, size_t size)
|
Line 165 erealloc3(void *ptr, size_t nmemb, size_t size)
|
size *= nmemb; |
size *= nmemb; |
ptr = ptr ? realloc(ptr, size) : malloc(size); |
ptr = ptr ? realloc(ptr, size) : malloc(size); |
if (ptr == NULL) |
if (ptr == NULL) |
fatalx_nodebug(NULL); | fatal_nodebug(NULL); |
return ptr; |
return ptr; |
} |
} |
|
|
#ifdef notyet |
|
/* |
/* |
* erecalloc() realloc(3)s nmemb * msize bytes and exits with an error |
* erecalloc() realloc(3)s nmemb * msize bytes and exits with an error |
* if overflow would occur or if the system malloc(3)/realloc(3) fails. |
* if overflow would occur or if the system malloc(3)/realloc(3) fails. |
* On success, the new space is zero-filled. You can call ereallocz() | * On success, the new space is zero-filled. You can call erealloc() |
* with a NULL pointer even if the system realloc(3) does not support this. |
* with a NULL pointer even if the system realloc(3) does not support this. |
*/ |
*/ |
void * |
void * |
Line 189 erecalloc(void *ptr, size_t onmemb, size_t nmemb, size
|
Line 188 erecalloc(void *ptr, size_t onmemb, size_t nmemb, size
|
size = nmemb * msize; |
size = nmemb * msize; |
ptr = ptr ? realloc(ptr, size) : malloc(size); |
ptr = ptr ? realloc(ptr, size) : malloc(size); |
if (ptr == NULL) |
if (ptr == NULL) |
fatalx_nodebug(NULL); | fatal_nodebug(NULL); |
if (nmemb > onmemb) { |
if (nmemb > onmemb) { |
size = (nmemb - onmemb) * msize; |
size = (nmemb - onmemb) * msize; |
memset((char *)ptr + (onmemb * msize), 0, size); |
memset((char *)ptr + (onmemb * msize), 0, size); |
} |
} |
return ptr; |
return ptr; |
} |
} |
#endif |
|
|
|
/* |
/* |
* estrdup() is like strdup(3) except that it exits with an error if |
* estrdup() is like strdup(3) except that it exits with an error if |
Line 254 easprintf(char **ret, const char *fmt, ...)
|
Line 252 easprintf(char **ret, const char *fmt, ...)
|
va_end(ap); |
va_end(ap); |
|
|
if (len == -1) |
if (len == -1) |
fatalx_nodebug(NULL); | fatal_nodebug(NULL); |
return len; |
return len; |
} |
} |
|
|
Line 268 evasprintf(char **ret, const char *format, va_list arg
|
Line 266 evasprintf(char **ret, const char *format, va_list arg
|
int len; |
int len; |
|
|
if ((len = vasprintf(ret, format, args)) == -1) |
if ((len = vasprintf(ret, format, args)) == -1) |
fatalx_nodebug(NULL); | fatal_nodebug(NULL); |
return len; |
return len; |
} |
} |