]> git.llucax.com Git - z.facultad/75.06/emufs.git/blobdiff - tipo3/param_cte.c
* Comento EMUFS para Doxygen
[z.facultad/75.06/emufs.git] / tipo3 / param_cte.c
index 149ece64f5574f98fd285fffb2f8ad8a03cd6880..0b2cc83ce9914d79917d060e071eef1a68252e1c 100644 (file)
@@ -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(&reg,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(&reg,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(&reg_b,sizeof(BLOCK_REG_T),1,f_block_reg);