version 1.1, 1996/12/16 20:38:07 |
version 1.2, 1999/03/01 16:40:08 |
|
|
/* $NetBSD$ */ |
/* $NetBSD$ */ |
|
|
/* |
/* |
* Copyright 1996 John D. Polstra. |
* Copyright 1996 John D. Polstra. |
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
*/ |
|
|
|
#include <sys/cdefs.h> |
#include "rtldenv.h" |
#include "rtldenv.h" |
#include <stddef.h> |
#include <stddef.h> |
|
#include <errno.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
|
void * |
void * |
xcalloc(size_t size) |
xcalloc(size) |
|
size_t size; |
{ |
{ |
return memset(xmalloc(size), 0, size); |
return memset(xmalloc(size), 0, size); |
} |
} |
|
|
void * |
void * |
xmalloc(size_t size) |
xmalloc(size) |
|
size_t size; |
{ |
{ |
void *p = malloc(size); |
void *p = malloc(size); |
if(p == NULL) |
if (p == NULL) |
xerr(1, "Out of memory"); |
xerr(1, "%s", xstrerror(errno)); |
return p; |
return p; |
} |
} |
|
|
char * |
char* |
xstrdup(const char *s) |
xstrdup(s) |
|
const char *s; |
{ |
{ |
char *p = strdup(s); |
char *p = strdup(s); |
if(p == NULL) |
if (p == NULL) |
xerr(1, "Out of memory"); |
xerr(1, "%s", xstrerror(errno)); |
return p; |
return p; |
} |
} |