diff options
| author | Pixel <> | 2001-04-15 01:15:02 +0000 | 
|---|---|---|
| committer | Pixel <> | 2001-04-15 01:15:02 +0000 | 
| commit | 1d2c4bd4e380395c68151d40239d1539d39fdd91 (patch) | |
| tree | 5d257d14007c3a67ac716c01c8334878483c3697 /lib/hash.c | |
| parent | a984cf3f28d3a5935c84f96f6da3bc7bd39a9ff1 (diff) | |
Assembleur
Diffstat (limited to 'lib/hash.c')
| -rw-r--r-- | lib/hash.c | 36 | 
1 files changed, 10 insertions, 26 deletions
@@ -2,20 +2,17 @@  #include <stdlib.h>  #include <string.h>  #include "hash.h" +#include "exceptions.h" +#include "config.h"  static char *CHAINEHACHAGE = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"; -static void TraitementDesErreurs(int codeerreur) -{ -	if (codeerreur == 1) { -		printf("\tErreur d'allocation\n"); -	} else { -		printf("\tUne autre erreur...\n"); -	} -} -  static int FonctionHachage(char *clef)  {  	unsigned int i; +	 +	if (!clef) { +		exception(1, _("Internal error into hashing")); +	}  	for (i = 0; i < strlen(CHAINEHACHAGE); i++) {  		if (clef[0] == CHAINEHACHAGE[i]) { @@ -29,11 +26,8 @@ _Element CreerElement(char *Nom, _TypeVariable Var)  {  	_Element e; -	e.NomVar = strdup(Nom); +	e.NomVar = Estrdup(Nom); -	if (e.NomVar == NULL) { -		TraitementDesErreurs(1); -	}  	e.Variable = Var;  	return (e);  } @@ -43,18 +37,8 @@ static _ListeChaine InserTete(_ListeChaine l, _Element e)  	_ListeChaine aux;  	unsigned int i; -	aux = (_ListeChaine) malloc(sizeof(struct _LstChn)); - -	if (aux == NULL) { -		TraitementDesErreurs(1); -		return (NULL); -	} -	aux->Elem.NomVar = (char *) malloc(sizeof(char) * (strlen(e.NomVar) + 1)); - -	if (aux->Elem.NomVar == NULL) { -		TraitementDesErreurs(1); -		return (NULL); -	} +	aux = (_ListeChaine) Emalloc(sizeof(struct _LstChn)); +	aux->Elem.NomVar = (char *) Emalloc(sizeof(char) * (strlen(e.NomVar) + 1));  	for (i = 0; i <= strlen(e.NomVar); i++) {  		aux->Elem.NomVar[i] = e.NomVar[i];  	} @@ -174,7 +158,7 @@ int Initialise(_TableauVariable * t)  {  	unsigned int i; -	(*t) = (_TableauVariable) malloc(sizeof(_ListeChaine) * strlen(CHAINEHACHAGE)); +	(*t) = (_TableauVariable) Emalloc(sizeof(_ListeChaine) * strlen(CHAINEHACHAGE));  	for (i = 0; i < strlen(CHAINEHACHAGE); i++) {  		(*t)[i] = NULL;  	}  | 
