Re: Fw: libxvidcore decompression

Dark Sylinc <[email protected]>
Newsgroups gmane.comp.video.xvid.devel
Message-ID <[email protected]>
Hi,
You said it's already fixed, but I saw many important problems in your code:

>#define BUFFER_SIZE (1024*1024*3)
>FILE *fpi;
>long lFileSize = 0;
>unsigned char *gmp4_buffer = 0;

>gmp4_buffer = (unsigned char *)malloc(BUFFER_SIZE);
Later you do:
>gmp4_buffer = (unsigned char *) malloc (lFileSize);

That's a MEMORY LEAK!!! You lose track of the previous memory pointer, thus you won't be able to free it later.
Creating a buffer with "BUFFER_SIZE" is pointless anyway. Remove that line. 

>if(gmp4_buffer==0)
>{
>Msg(TEXT("gmp4_buffer is empty, cannot read from file"));
>}

Wrong!
if (gmp4_buffer==0) then the system failed to allocate the ammount of memory RAM you requested (with malloc...). It has nothing to do with reading the file. (Of course, if you don't have space in memory where to store what you've read, the reading routine will also fail, and possibly crash)

Cheers
Dark Sylinc



      Tarjeta de crédito Yahoo! de Banco Supervielle.
Solicitá tu nueva Tarjeta de crédito. De tu PC directo a tu casa. www.tuprimeratarjeta.com.ar
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.