Leaks in FFPLAY

Hi,
I came across this piece of code

*pkt = pkt1->pkt;
av_free(pkt1);

Pkt1 is a struct defined as

typedef struct AVPacketList {
AVPacket pkt;
struct AVPacketList *next;
} AVPacketList;

I do not understand if we are freeing something then how can use it again. ?

thanks,

  Office firewalls, cyber cafes, college labs, don't allow you to download CHAT? Click here: http://in.messenger.yahoo.com/webmessengerpromo.php

Hi,
I came across this piece of code

*pkt = pkt1->pkt;
av_free(pkt1);

Pkt1 is a struct defined as

typedef struct AVPacketList {
AVPacket pkt;
struct AVPacketList *next;
} AVPacketList;

I do not understand if we are freeing something then how can use it
again. ?

I haven’t looked at the existing code but you can always reassign the
pointer with a “new” statement. It wouldn’t have any of the previous
data in it but it would still be usable.>>> On 5/10/2007 at 7:54 PM, Pankaj <panky_13210 at yahoo.com> wrote:


Lilith

You can’t or maybe I don’t understand what you mean. That said, this seems
like a simple algorithm in C where an element is removed from a linked list.
The puzzling point might be that ‘*pkt’ now contains a copy(!) of the
former ‘pkt1->pkt’, and the copy is independent from the original.

BTW: this is completely off-topic here and rather belongs into a C beginners
area. Further, check ACCU’s website for book reviews, it’s really hard to
learn C only from the net.

cheers

UliOn Friday 11 May 2007 02:54:31 Pankaj wrote:

*pkt = pkt1->pkt;
av_free(pkt1);

Pkt1 is a struct defined as

typedef struct AVPacketList {
AVPacket pkt;
struct AVPacketList *next;
} AVPacketList;

I do not understand if we are freeing something then how can use it again?

The value of pkt1->pkt is being copied (and not the pointer).

Just like this:
int f;
int *p = new int;
*p = 1;
f = *p;
delete p;

if(f == 1) {
printf(“Yay!\n”);
}

return 0;

You’ll notice that f is still usable after p is destroyed.On Thu, 2007-05-10 at 17:54 -0700, Pankaj wrote:

Hi,
I came across this piece of code

*pkt = pkt1->pkt;
av_free(pkt1);

Pkt1 is a struct defined as

typedef struct AVPacketList {
AVPacket pkt;
struct AVPacketList *next;
} AVPacketList;

I do not understand if we are freeing something then how can use it
again. ?

thanks,


Coleman Kane

thanks for the explanation … Actually i was looking into the leaks that i am getting while playing .mp3 FFMPEG and just got confused. … thanks for clearing it.

Regards,
Pankaj> ----- Original Message -----

From: ckane@intellitree.com (Coleman Kane)
To: A list for developers using the SDL library. (includes SDL-announce)
Sent: Friday, 11 May, 2007 10:25:16 AM
Subject: Re: [SDL] Leaks in FFPLAY

On Thu, 2007-05-10 at 17:54 -0700, Pankaj wrote:

Hi,
I came across this piece of code

*pkt = pkt1->pkt;
av_free(pkt1);

Pkt1 is a struct defined as

typedef struct AVPacketList {
AVPacket pkt;
struct AVPacketList *next;
} AVPacketList;

I do not understand if we are freeing something then how can use it
again. ?

thanks,

The value of pkt1->pkt is being copied (and not the pointer).

Just like this:
int f;
int *p = new int;
*p = 1;
f = *p;
delete p;

if(f == 1) {
printf(“Yay!\n”);
}

return 0;

You’ll notice that f is still usable after p is destroyed.


Coleman Kane


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Yahoo! India Answers: Share what you know. Learn something new
http://in.answers.yahoo.com/