X-Git-Url: https://git.llucax.com/z.facultad/75.06/emufs.git/blobdiff_plain/3d7c873614ca81c1590a4cbb7e786ffda64755d6..6e27e8a6e12788d7be596b884e6f81337f583d53:/emufs/emufs.c?ds=sidebyside diff --git a/emufs/emufs.c b/emufs/emufs.c index 42c81f1..de9856e 100644 --- a/emufs/emufs.c +++ b/emufs/emufs.c @@ -290,7 +290,18 @@ EMUFS *emufs_abrir(const char *filename) int emufs_destruir(EMUFS *e) { + INDICE *del, *cur; + if (e == NULL) return 1; + + /* libero indices */ + cur = e->indices; + while (cur) { + del = cur; + cur = cur->sig; + emufs_indice_destruir(e, cur); + } + free(e->nombre); free(e); return 0; @@ -472,6 +483,7 @@ int guardar_indice(EMUFS *emu, char *nombre, INDICE_FUNCION funcion, INDICE_TIPO fwrite(&cant, 1, sizeof(int), fp); fwrite(indices, cant, sizeof(t_Indice), fp); fclose(fp); + free(indices); return 1; } @@ -495,7 +507,6 @@ EMUFS_BLOCK_ID emufs_create_new_block(EMUFS *emu) dummy = (char*)malloc(emu->tam_bloque); memset(dummy, 0, emu->tam_bloque); fwrite(dummy, emu->tam_bloque, 1, fp); - printf("new_block ftell = %d\n", ftell(fp)); switch(emu->tipo){ case T1: num = (ftell(fp)-sizeof(EMUFS_Tipo)-sizeof(EMUFS_BLOCK_SIZE))/emu->tam_bloque; break;