summaryrefslogtreecommitdiff
path: root/lib/hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/hash.c')
-rw-r--r--lib/hash.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/hash.c b/lib/hash.c
index 6d890f7..2850444 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -19,7 +19,7 @@ static int FonctionHachage(char *clef)
return (i);
}
}
- return (-1);
+ return (strlen(CHAINEHACHAGE));
}
_Element CreerElement(char *Nom, _TypeVariable Var)
@@ -95,7 +95,7 @@ char SupprimerDansTab(_TableauVariable * t, char *Nom)
{
int index = FonctionHachage(Nom);
- if (0 <= index && index < strlen(CHAINEHACHAGE)) {
+ if (0 <= index && index <= strlen(CHAINEHACHAGE)) {
Supprimer(&((*t)[index]), Nom);
} else {
return (0);
@@ -107,7 +107,7 @@ char InsererVarDansTab(_TableauVariable * t, _Element e)
{
int index = FonctionHachage(e.NomVar);
- if (0 <= index && index < strlen(CHAINEHACHAGE)) {
+ if (0 <= index && index <= strlen(CHAINEHACHAGE)) {
(*t)[index] = InserTete((*t)[index], e);
} else {
return (0);
@@ -158,8 +158,8 @@ int Initialise(_TableauVariable * t)
{
unsigned int i;
- (*t) = (_TableauVariable) Emalloc(sizeof(_ListeChaine) * strlen(CHAINEHACHAGE));
- for (i = 0; i < strlen(CHAINEHACHAGE); i++) {
+ (*t) = (_TableauVariable) Emalloc(sizeof(_ListeChaine) * (strlen(CHAINEHACHAGE) + 1));
+ for (i = 0; i <= strlen(CHAINEHACHAGE); i++) {
(*t)[i] = NULL;
}
return (i);
@@ -169,7 +169,7 @@ void DetruitTab(_TableauVariable * t)
{
int i;
- for (i = 0; i < strlen(CHAINEHACHAGE); i++) {
+ for (i = 0; i <= strlen(CHAINEHACHAGE); i++) {
Detruit(&((*t)[i]));
}