aboutsummaryrefslogtreecommitdiffstats
path: root/dist-tools/upload
blob: 3a76ee49de1438bea65b87da2b341dfca9eb0172 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
 * xmalloc.c -- allocate space or die 
 *
 * Copyright 1998 by Eric S. Raymond.
 * For license terms, see the file COPYING in this directory.
 */

#include "config.h"
#include <sys/types.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#if defined(STDC_HEADERS)
#include
i18n.h" #if defined(HAVE_VOIDPOINTER) #define XMALLOCTYPE void #else #define XMALLOCTYPE char #endif XMALLOCTYPE * xmalloc (size_t n) { XMALLOCTYPE *p; p = (XMALLOCTYPE *) malloc(n); if (p == (XMALLOCTYPE *) 0) { report(stderr, GT_("malloc failed\n")); exit(PS_UNDEFINED); } return(p); } XMALLOCTYPE * xrealloc (XMALLOCTYPE *p, size_t n) { if (p == 0) return xmalloc (n); p = (XMALLOCTYPE *) realloc(p, n); if (p == (XMALLOCTYPE *) 0) { report(stderr, GT_("realloc failed\n")); exit(PS_UNDEFINED); } return p; } char *xstrdup(const char *s) { char *p; p = (char *) xmalloc(strlen(s)+1); strcpy(p,s); return p; } #if !defined(HAVE_STRDUP) char *strdup(const char *s) { char *p; p = (char *) malloc(strlen(s)+1); strcpy(p,s); return p; } #endif /* !HAVE_STRDUP */ /* xmalloc.c ends here */