X-Git-Url: https://git.llucax.com/z.facultad/75.06/emufs.git/blobdiff_plain/dea2e663e8a5afc489e331721832c3dbfb4d2f09..a7c8fea340860d01b4689b22ffa5b193680dd6f9:/emufs/emufs.c?ds=sidebyside diff --git a/emufs/emufs.c b/emufs/emufs.c index 3803cf5..8ad9604 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; @@ -503,7 +514,7 @@ EMUFS_BLOCK_ID emufs_create_new_block(EMUFS *emu) } fclose(fp); free(dummy); - return num; + return num-1; } /*devuelve un numero de bloque siguiente al ultimo*/ @@ -527,7 +538,6 @@ EMUFS_BLOCK_ID emufs_get_new_block_number(EMUFS *emu) switch(emu->tipo){ case T1: num = (ftell(fp)-sizeof(EMUFS_Tipo)-sizeof(EMUFS_BLOCK_SIZE))/emu->tam_bloque; if (ftell(fp) == sizeof(EMUFS_Tipo)+sizeof(EMUFS_BLOCK_SIZE)) num = 0; - PERR("PASE"); break; case T3: num = (ftell(fp)-sizeof(EMUFS_Tipo)-sizeof(EMUFS_BLOCK_SIZE)-sizeof(EMUFS_REG_SIZE))/emu->tam_bloque; if (ftell(fp) == sizeof(EMUFS_Tipo)+sizeof(EMUFS_BLOCK_SIZE)+sizeof(EMUFS_REG_SIZE)) num = 0;