From 1d2c4bd4e380395c68151d40239d1539d39fdd91 Mon Sep 17 00:00:00 2001 From: Pixel <> Date: Sun, 15 Apr 2001 01:15:02 +0000 Subject: Assembleur --- lib/hash.c | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) (limited to 'lib/hash.c') diff --git a/lib/hash.c b/lib/hash.c index 58b6f9f..bd406c8 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -2,20 +2,17 @@ #include #include #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; } -- cgit v1.2.3