Intento implementar un Hash en C. El programa compila, pero en el archivo myHash.h tira la siguiente advertencia:
warning: passing argument 1 of 'enlistar' from incompatible pointer type [enabled by default]
Archivo myHash.h
#ifndef MYHASH_H_INCLUDED
#define MYHASH_H_INCLUDED
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#define HASHMAX 10
typedef struct nodoL {
int info;
struct nodoL * sig;
struct nodoL * ant;
} * lista;
// DEFINICIÓN DE LAS FUNCIONES
//************* HASH **********
typedef lista Hash[HASHMAX];
int HashClave(int n);
void HashInsertar(Hash *h, int e);
void HashMostrar(Hash h);
void HashBuscar(Hash h, int n);
//******** LISTA *******
void enlistar (lista *L, int n);
int mostrar(lista L);/* muestra por pantalla los valores de L, en forma recursiva */
void borrar(lista *L, int n);
#endif // MYHASH_H_INCLUDED
Todo bien.
Archivo myHash.c
#include "myHash.h"
int HashClave (int n)
{
return n%HASHMAX;
}
void HashInsertar (Hash *h, int e){
enlistar ((h)[HashClave(e)],e);
}
void enlistar (lista *L, int n){ //<--note: expected 'struct nodoL **' but argument is of type 'struct nodoL *'
lista aux = (lista)malloc(sizeof( struct nodoL ));
if(*L==NULL){
aux -> info = n;
aux -> sig = *L;
*L=aux;
}
else{
if((*L)->info>n){// Para que quede ordenado
aux -> info = n;
aux -> sig = *L;
*L=aux;
}
else{
enlistar((*L)->sig,n); //<-- warning: passing argument 1 of 'enlistar' from incompatible pointer type [enabled by default]
}
}
}
int mostrar (lista L)
{
int i=0;
if(L!=NULL)
{
i=1;
printf("[%d]->",L->info);
mostrar(L->sig);
}
return i;
}
void HashMostrar(Hash h){
int i, n;
for (n=0;n<HASHMAX;n++){
printf("Hash [%d]: ",n);
i=mostrar(h[n]);
if(i==0)printf("Lista vacia \n\n");
else printf("# \n\n");
}
}
void borrar(lista *L, int n)
{
lista aux = *L; //puntero auxiliar al primer nodo
lista ant = NULL;
if(aux==NULL)
{
printf("Error: Lista vacia");
}
else
{
while (aux->info!=n&&aux->sig!=NULL)
{
ant=aux;
aux=aux->sig;
}
if(aux->sig==NULL&&aux->info!=n)
printf("Error, numero no se encuentra en la lista");
else
{
ant->sig=aux->sig;
free (aux); //elimino el nodo de la memoria
}
}
}
Adicionalmente tira la siguiente nota:
note: expected 'struct nodoL **' but argument is of type 'struct nodoL *' en la línea marcada.
¿Qué puede estar pasando?