]> git.llucax.com Git - z.facultad/75.06/emufs.git/blobdiff - emufs/indices.c
bufford andando.
[z.facultad/75.06/emufs.git] / emufs / indices.c
index 34d347effaf00420a3172c509a47e02b596b75f7..f7a0ff2f03b7b009cb275d769fcc2457fac04787 100644 (file)
@@ -88,8 +88,12 @@ void emufs_indice_destruir(EMUFS *emu, INDICE *i)
 {
        /* TODO Sacar el indice de la lista en EMUFS */
 
+       if (!i) return;
+
        if (i->tipo == IDX_STRING)
                emufs_destruir(i->emu_string);
+       if (i->funcion != IND_PRIMARIO)
+               emufs_destruir(i->emu_mult);
        free(i->filename);
        free(i->nombre);
        free(i);
@@ -133,10 +137,10 @@ CLAVE emufs_indice_generar_clave_desde_valor(INDICE *idx, char *data)
                        /* Hack feo :-D */
                        sprintf(salvar, "%s", data);
                        k.i_clave = idx->emu_string->grabar_registro(idx->emu_string,
-                                                                               salvar,
-                                                                               strlen(salvar)+1,
-                                                                               &error
-                                                                       );
+                               salvar,
+                               strlen(salvar)+1,
+                               &error
+                       );
        }
 
        return k;
@@ -159,10 +163,10 @@ CLAVE emufs_indice_generar_clave(INDICE *idx, char *data)
                        PERR(idx->nombre);
                        PERR(data+idx->offset);
                        k.i_clave = idx->emu_string->grabar_registro(idx->emu_string,
-                                                                               data+idx->offset,
-                                                                               strlen(data+idx->offset)+1,
-                                                                               &error
-                                                                       );
+                               data+idx->offset,
+                               strlen(data+idx->offset)+1,
+                               &error
+                       );
        }
 
        return k;
@@ -244,3 +248,14 @@ void emufs_indice_obtener_valor_desde_clave(INDICE *idx, CLAVE k, void *dst)
                        free(leido);
        }
 }
+
+
+void emufs_indice_borrar(INDICE *primero, CLAVE k, INDICE_DATO dato)
+{
+       INDICE *iter = primero;
+
+       while (iter) {
+               iter->borrar_entrada(iter, k, dato);
+               iter = iter->sig;
+       }
+}