› Foros › PC › Software libre
void EscribirFicheroBinario ( LISTA& lista, string argumento,bool& correcto)
{
ofstream fbe ;
// TCancionBinaria aux ;
pNodo p ;
p = lista ;
bool error = false ;
fbe.open(argumento.c_str(),ios::out | ios::binary);
if ( !fbe.is_open())
{
correcto = false ;
cout << E5 << " " << argumento << endl ;
}
else
{
// lo que tenga que hacer
while (p != NULL && !error)
{
TCancionBinaria* aux = new TCancionBinaria ;
strncpy(aux->autor,p->autor.c_str(),TAMAUTOR-1);
aux->autor[TAMAUTOR-1]='\0' ;
strncpy(aux->album,p->album.c_str(),TAMALBUM-1);
aux->album[TAMALBUM-1]='\0' ;
strncpy(aux->titulo,p->titulo.c_str(),TAMTITULO-1);
aux->titulo[TAMTITULO-1]='\0' ;
aux->valoracion = p->valoracion ;
strncpy(aux->url,p->url.c_str(),TAMURL-1);
aux->url[TAMURL-1]='\0' ;
strncpy(aux->imagen,p->imagen.c_str(),TAMIMG-1);
aux->imagen[TAMIMG-1]='\0' ;
fbe.write((const char *)&aux, sizeof([b]TCancionBinaria[/b]));
if (fbe.fail() && !fbe.eof()) error=true;
delete aux ;
aux = NULL ;
p = p -> siguiente ;
}
}
fbe.close();
}
==12475== Syscall param write(buf) points to uninitialised byte(s)
==12475== at 0x40007D2: (within /lib/ld-2.8.90.so)
==12475== by 0x409BFD0: std::basic_filebuf<char, std::char_traits<char> >::_M_convert_to_external(char*, int) (in /usr/lib/libstdc++.so.6.0.10)
==12475== by 0x409C121: std::basic_filebuf<char, std::char_traits<char> >::overflow(int) (in /usr/lib/libstdc++.so.6.0.10)
==12475== by 0x409C86F: std::basic_filebuf<char, std::char_traits<char> >::_M_terminate_output() (in /usr/lib/libstdc++.so.6.0.10)
==12475== by 0x409CDE7: std::basic_filebuf<char, std::char_traits<char> >::close() (in /usr/lib/libstdc++.so.6.0.10)
==12475== by 0x409E304: std::basic_ofstream<char, std::char_traits<char> >::close() (in /usr/lib/libstdc++.so.6.0.10)
==12475== by 0x805647A: EscribirFicheroBinario(Tnodo*&, std::string, bool&) (libcol.cc:673)
==12475== by 0x8056F70: ModoNoInteractivo(char* const*, int, Tnodo*&, tOpcion&) (libcol.cc:343)
==12475== by 0x804AB44: main (gestcol.cc:65)
==12475== Address 0x4316190 is 8 bytes inside a block of size 8,192 alloc'd
==12475== at 0x402505E: operator new[](unsigned) (vg_replace_malloc.c:268)
==12475== by 0x409B7D2: std::basic_filebuf<char, std::char_traits<char> >::_M_allocate_internal_buffer() (in /usr/lib/libstdc++.so.6.0.10)
==12475== by 0x409CF91: std::basic_filebuf<char, std::char_traits<char> >::open(char const*, std::_Ios_Openmode) (in /usr/lib/libstdc++.so.6.0.10)
==12475== by 0x409D0F5: std::basic_ofstream<char, std::char_traits<char> >::open(char const*, std::_Ios_Openmode) (in /usr/lib/libstdc++.so.6.0.10)
==12475== by 0x80561FF: EscribirFicheroBinario(Tnodo*&, std::string, bool&) (libcol.cc:643)
==12475== by 0x8056F70: ModoNoInteractivo(char* const*, int, Tnodo*&, tOpcion&) (libcol.cc:343)
==12475== by 0x804AB44: main (gestcol.cc:65)
fbe.write((const char *)&aux, sizeof(TCancionBinaria));
fbe.write(reinterpret_cast<const char *>(aux), sizeof(*aux));
==19563== Syscall param write(buf) points to uninitialised byte(s)
==19563== at 0x40007D2: (within /lib/ld-2.8.90.so)
==19563== by 0x409BFD0: std::basic_filebuf<char, std::char_traits<char> >::_M_convert_to_external(char*, int) (in /usr/lib/libstdc++.so.6.0.10)
==19563== by 0x409C121: std::basic_filebuf<char, std::char_traits<char> >::overflow(int) (in /usr/lib/libstdc++.so.6.0.10)
==19563== by 0x409C86F: std::basic_filebuf<char, std::char_traits<char> >::_M_terminate_output() (in /usr/lib/libstdc++.so.6.0.10)
==19563== by 0x409CDE7: std::basic_filebuf<char, std::char_traits<char> >::close() (in /usr/lib/libstdc++.so.6.0.10)
==19563== by 0x409E304: std::basic_ofstream<char, std::char_traits<char> >::close() (in /usr/lib/libstdc++.so.6.0.10)
==19563== by 0x8056460: EscribirFicheroBinario(Tnodo*&, std::string, bool&) (libcol.cc:674)
==19563== by 0x804AF0C: main (gestcol.cc:131)
==19563== Address 0x42c407e is 174 bytes inside a block of size 8,192 alloc'd
==19563== at 0x402505E: operator new[](unsigned) (vg_replace_malloc.c:268)
==19563== by 0x409B7D2: std::basic_filebuf<char, std::char_traits<char> >::_M_allocate_internal_buffer() (in /usr/lib/libstdc++.so.6.0.10)
==19563== by 0x409CF91: std::basic_filebuf<char, std::char_traits<char> >::open(char const*, std::_Ios_Openmode) (in /usr/lib/libstdc++.so.6.0.10)
==19563== by 0x409D0F5: std::basic_ofstream<char, std::char_traits<char> >::open(char const*, std::_Ios_Openmode) (in /usr/lib/libstdc++.so.6.0.10)
==19563== by 0x80561FF: EscribirFicheroBinario(Tnodo*&, std::string, bool&) (libcol.cc:643)
==19563== by 0x804AF0C: main (gestcol.cc:131)