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

#include "common.h"

unsigned char * strcpy_alloc(unsigned char** to, const unsigned char* from)
{
	if ( (*to = malloc( sizeof(char) * (strlen(from)+1) ))== NULL ){
		fprintf (stderr,
			"%s: Erro na alocação de memória: %s\n",
			PROG_NAME, strerror (errno));
		exit(1);

	}
	return strcpy(*to, from);
}

unsigned long int * alloc_registers(unsigned long int **R, unsigned int n )
{
	if ( (*R = malloc( sizeof(unsigned long int) * n ))== NULL ){
		fprintf (stderr,
			"%s: Erro na alocação de memória: %s\n",
			PROG_NAME, strerror (errno));
		exit(1);

	}
	return *R;
}
