X-Git-Url: https://git.llucax.com/z.facultad/75.06/emufs.git/blobdiff_plain/d810be9c12d7287014d4af8dfd480e27c64a325b..2bbb263b7b66a8b883e1700cdf4552369b17696e:/emufs_gui/articulos.c diff --git a/emufs_gui/articulos.c b/emufs_gui/articulos.c index 7fda604..b9605c2 100644 --- a/emufs_gui/articulos.c +++ b/emufs_gui/articulos.c @@ -83,6 +83,8 @@ t_LstArticulos *art_cargar(const char *filename, int tipo, int tam_bloque) if (filename != NULL) { document = xmlReadFile(filename, "ISO-8859-1",0); if (document == NULL) { + free(tmp); + lst_articulos = NULL; return NULL; } @@ -151,9 +153,14 @@ int art_liberar(t_LstArticulos *l) { if (l == NULL) l = lst_articulos; if (l == NULL) return 1; + t_Reg_Articulo *del; emufs_destruir(l->fp); - /* TODO : Liberar lista */ + while (l->primero) { + del = l->primero; + l->primero = l->primero->sig; + free(del); + } free(l); lst_articulos = NULL; @@ -434,7 +441,7 @@ int procesar_leer_articulo(t_Articulo *dst, void *src, EMUFS_REG_SIZE size, t_Ls ini = fin+1; fin = (char *)src+size; - memcpy(dst->emin, ini, fin-ini+1); + memcpy(dst->emin, ini, fin-ini); break; case T3: @@ -463,6 +470,7 @@ void *procesar_guardar_articulo(t_Articulo *src, EMUFS_REG_SIZE *size, t_LstArti (*size) = i[0]+i[1]+i[2]+i[3]+i[4]+i[5]; tmp = (char *)malloc((*size)); if (tmp == NULL) return NULL; + memset(tmp, 0, *size); memcpy(tmp, &src->numero, i[0]); memcpy(tmp+i[0], src->desc, i[1]); memcpy(tmp+i[0]+i[1], src->presentacion, i[2]); @@ -475,6 +483,7 @@ void *procesar_guardar_articulo(t_Articulo *src, EMUFS_REG_SIZE *size, t_LstArti * registro se vea bien */ tmp = (char *)malloc(sizeof(t_Articulo)); + memset(tmp, '*', sizeof(t_Articulo)); memcpy(tmp, from, sizeof(t_Articulo)); (*size) = sizeof(t_Articulo); }