X-Git-Url: https://git.llucax.com/z.facultad/75.06/emufs.git/blobdiff_plain/885b60b3ea2aed49543ea87490ff971a68a5c2f1..92aca5d432abb85476f6c100fb55190cd5947a00:/tipo3/param_cte.c diff --git a/tipo3/param_cte.c b/tipo3/param_cte.c index 149ece6..0b2cc83 100644 --- a/tipo3/param_cte.c +++ b/tipo3/param_cte.c @@ -167,7 +167,10 @@ int grabar_registro(EMUFS *emu, void *ptr, unsigned long tam) /*printf("FS = %d\n", fs);*/ reg.free_space = emu->tam_bloque - tam-sizeof(int); /*lo guardo en el archivo al final "a+"*/ - if ( (f_block_free = fopen(name_f_free,"a+"))==NULL ) return -1; /*ERROR*/ + if ( (f_block_free = fopen(name_f_free,"a+"))==NULL ) { + free(bloque); + return -1; /*ERROR*/ + } fwrite(®,sizeof(BLOCK_FREE_T),1,f_block_free); fclose(f_block_free); } else { @@ -189,7 +192,10 @@ int grabar_registro(EMUFS *emu, void *ptr, unsigned long tam) } /*actualizo el archivo de espacios libres*/ /*busco el bloque que modifique*/ - if ( (f_block_free = fopen(name_f_free,"r+")) == NULL) return -1; /*ERROR*/ + if ( (f_block_free = fopen(name_f_free,"r+")) == NULL) { + free(bloque); + return -1; /*ERROR*/ + } while ( !feof(f_block_free) ){ fread(®,sizeof(BLOCK_FREE_T),1,f_block_free); if ( reg.block == num_bloque ){ @@ -203,7 +209,10 @@ int grabar_registro(EMUFS *emu, void *ptr, unsigned long tam) } /*actualizo el archivo de bloques y registros*/ - if ( (f_block_reg = fopen(name_f_block_reg,"ab+"))==NULL ) return -1; /*ERROR*/ + if ( (f_block_reg = fopen(name_f_block_reg,"ab+"))==NULL ) { + free(bloque); + return -1; /*ERROR*/ + } reg_b.block = reg.block; reg_b.id_reg = ID_aux; fwrite(®_b,sizeof(BLOCK_REG_T),1,f_block_reg);