X-Git-Url: https://git.llucax.com/z.facultad/75.06/emufs.git/blobdiff_plain/d523d5c3a87c794485680019e0343c490357574e..ec7d4a565379cd88c256198788960d559326e47a:/emufs/fsc.c?ds=sidebyside diff --git a/emufs/fsc.c b/emufs/fsc.c index a94a2f1..d9b26bb 100644 --- a/emufs/fsc.c +++ b/emufs/fsc.c @@ -205,31 +205,34 @@ int emufs_fsc_actualizar(EMUFS *emu, EMUFS_BLOCK_ID n_marker, EMUFS_FREE n_frees } /* Me devuelve el ID del bloque u Offset del Gap donde quepa un registro, y guarda en n_freespace el espacio libre actualizado */ -EMUFS_BLOCK_ID emufs_fsc_buscar_lugar(EMUFS *emu, EMUFS_FREE n_RegSize, EMUFS_FREE *n_freespace) +EMUFS_BLOCK_ID emufs_fsc_buscar_lugar(EMUFS *emu, EMUFS_FREE regsize, EMUFS_FREE *freespace) { FILE *f_fsc; EMUFS_FSC reg; char name_f_fsc[255]; - unsigned short int b_Found = 0; + char found = 0; strcpy(name_f_fsc,emu->nombre); strcat(name_f_fsc, EMUFS_FSC_EXT); - if ( (f_fsc = fopen(name_f_fsc,"r"))==NULL ) return -1; + if ( (f_fsc = fopen(name_f_fsc,"r"))==NULL ) return EMUFS_NOT_FOUND; /* Inicializamos la estructura para devolver algun valor en concreto */ /* en caso de que no se halle un espacio libre apropiado */ - while(!feof(f_fsc) && !b_Found){ + while(!feof(f_fsc)){ if (fread(®,sizeof(EMUFS_FSC),1,f_fsc) != 1) continue; - if (reg.n_freespace >= n_RegSize) b_Found = 1; + if (reg.n_freespace >= regsize) { + found = 1; + break; + } } /* Si salio por error o por fin de archivo y no encontro space... */ - if (!b_Found) { - reg.n_marker = -1; - *n_freespace = emu->tam_bloque; + if (!found) { + reg.n_marker = EMUFS_NOT_FOUND; + *freespace = emu->tam_bloque; } - else *n_freespace = reg.n_freespace; + else *freespace = reg.n_freespace; fclose(f_fsc); return reg.n_marker;