/*
 *  common.c
 *  
 *
 *  Created by Charles Mercadal on Fri Jul 19 2002.
 *
 */

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>


#include "common.h"


void *xmalloc(size_t bsize)
{
    void *nbuf;
    
    if ((nbuf = malloc(bsize)) != NULL)
        return nbuf;
    else {
        perror(NULL);
        exit(1);
    }
}


void *xrealloc(void *optr, size_t nbsize)
{
    void *nbuf;
    
    if ((nbuf = realloc(optr, nbsize)) != NULL)
        return nbuf;
    else {
        perror(NULL);
        exit(1);
    }
}


char *xstrdup(const char *from)
{
    char *to;
    
    if ((to = strdup(from)) != NULL)
        return to;
    else {
        perror(NULL);
        exit(1);
    }
}
