ftp.nice.ch/pub/next/unix/mail/fetchmail.4.3.7.s.tar.gz#/fetchmail-4.3.7/xmalloc.c

This is xmalloc.c in view mode; [Download] [Up]

/*
 * xmalloc.c -- allocate space or die 
 *
 * For license terms, see the file COPYING in this directory.
 */

#include "config.h"
#include <stdio.h>
#include <errno.h>
#include <string.h>
#if defined(STDC_HEADERS)
#include  <stdlib.h>
#endif
#include "fetchmail.h"

#if defined(HAVE_VOIDPOINTER)
#define XMALLOCTYPE void
#else
#define XMALLOCTYPE char
#endif

XMALLOCTYPE *
xmalloc (int n)
{
    XMALLOCTYPE *p;

    p = (XMALLOCTYPE *) malloc(n);
    if (p == (XMALLOCTYPE *) 0)
	error(PS_UNDEFINED, errno, "malloc failed");
    return(p);
}

XMALLOCTYPE *
xrealloc (XMALLOCTYPE *p, int n)
{
    if (p == 0)
	return xmalloc (n);
    p = (XMALLOCTYPE *) realloc(p, n);
    if (p == (XMALLOCTYPE *) 0)
	error(PS_UNDEFINED, errno, "realloc failed");
    return p;
}

char *xstrdup(const char *s)
{
    char *p;
    p = (char *) xmalloc(strlen(s)+1);
    strcpy(p,s);
    return p;
}

/* xmalloc.c ends here */

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.