All of lore.kernel.org
 help / color / mirror / Atom feed
* Memory managment.
@ 2002-05-05 14:27 Peter Enderborg
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Enderborg @ 2002-05-05 14:27 UTC (permalink / raw)
  To: alsa-devel@lists.sourceforge.net

I have some memory problems with my alsa programming.
And I have tryed to do a small program to see whats wrong.
And I still have the same problem with this little program...


#include <alsa/asoundlib.h>
int main()
{
  while (1)
    {
      snd_seq_event_t *foo;
      foo = snd_seq_create_event();
      snd_seq_free_event(foo);
    }
  return 0;
}

I guess that I have missed some fundamental things about the events.
This on cvs version from 20020504


--
foo!




_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Memory managment.
@ 2002-05-05 17:35 Peter Enderborg
  2002-05-06  9:42 ` Takashi Iwai
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Enderborg @ 2002-05-05 17:35 UTC (permalink / raw)
  To: alsa-devel@lists.sourceforge.net

I have some memory problems with my alsa programming.
And I have tryed to do a small program to see whats wrong.
And I still have the same problem with this little program...


#include <alsa/asoundlib.h>
int main()
{
  while (1)
    {
      snd_seq_event_t *foo;
      foo = snd_seq_create_event();
      snd_seq_free_event(foo);
    }
  return 0;
}

I guess that I have missed some fundamental things about the events.
This on cvs version from 20020504


_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: bandwidth@sourceforge.net

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Memory managment.
  2002-05-05 17:35 Memory managment Peter Enderborg
@ 2002-05-06  9:42 ` Takashi Iwai
  2002-05-06 10:09   ` Peter Enderborg
  0 siblings, 1 reply; 7+ messages in thread
From: Takashi Iwai @ 2002-05-06  9:42 UTC (permalink / raw)
  To: Peter Enderborg; +Cc: alsa-devel@lists.sourceforge.net

Hi Peter,

At Sun, 05 May 2002 19:35:04 +0200,
Peter Enderborg wrote:
> 
> I have some memory problems with my alsa programming.
> And I have tryed to do a small program to see whats wrong.
> And I still have the same problem with this little program...
> 
> 
> #include <alsa/asoundlib.h>
> int main()
> {
>   while (1)
>     {
>       snd_seq_event_t *foo;
>       foo = snd_seq_create_event();
>       snd_seq_free_event(foo);
>     }
>   return 0;
> }
> 
> I guess that I have missed some fundamental things about the events.
> This on cvs version from 20020504

err..  please avoid using snd_seq_create_event(), or free the pointer
by normal free() call.  snd_seq_free_event() doesn't free the
malloc'ed pointer on alsa 0.9.

if there is no objection, i'll remove snd_seq_create_event() from
API, or put a warning at least.


Takashi

_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: bandwidth@sourceforge.net

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Memory managment.
  2002-05-06  9:42 ` Takashi Iwai
@ 2002-05-06 10:09   ` Peter Enderborg
  2002-05-06 10:37     ` Takashi Iwai
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Enderborg @ 2002-05-06 10:09 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel@lists.sourceforge.net

Takashi Iwai wrote:

> Hi Peter,
>
> At Sun, 05 May 2002 19:35:04 +0200,
> Peter Enderborg wrote:
> >
> > I have some memory problems with my alsa programming.
> > And I have tryed to do a small program to see whats wrong.
> > And I still have the same problem with this little program...
> >
> >
> > #include <alsa/asoundlib.h>
> > int main()
> > {
> >   while (1)
> >     {
> >       snd_seq_event_t *foo;
> >       foo = snd_seq_create_event();
> >       snd_seq_free_event(foo);
> >     }
> >   return 0;
> > }
> >
> > I guess that I have missed some fundamental things about the events.
> > This on cvs version from 20020504
>
> err..  please avoid using snd_seq_create_event(), or free the pointer
> by normal free() call.  snd_seq_free_event() doesn't free the
> malloc'ed pointer on alsa 0.9.
>

What is the correct way to create an event then?

>
> if there is no objection, i'll remove snd_seq_create_event() from
> API, or put a warning at least.
>
> Takashi

--
foo!




_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: bandwidth@sourceforge.net

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Memory managment.
  2002-05-06 10:09   ` Peter Enderborg
@ 2002-05-06 10:37     ` Takashi Iwai
  2002-05-06 11:01       ` Peter Enderborg
  2002-05-07  2:18       ` Ville Syrjälä
  0 siblings, 2 replies; 7+ messages in thread
From: Takashi Iwai @ 2002-05-06 10:37 UTC (permalink / raw)
  To: Peter Enderborg; +Cc: alsa-devel@lists.sourceforge.net

At Mon, 06 May 2002 12:09:57 +0200,
Peter Enderborg wrote:
> 
> Takashi Iwai wrote:
> 
> > Hi Peter,
> >
> > At Sun, 05 May 2002 19:35:04 +0200,
> > Peter Enderborg wrote:
> > >
> > > I have some memory problems with my alsa programming.
> > > And I have tryed to do a small program to see whats wrong.
> > > And I still have the same problem with this little program...
> > >
> > >
> > > #include <alsa/asoundlib.h>
> > > int main()
> > > {
> > >   while (1)
> > >     {
> > >       snd_seq_event_t *foo;
> > >       foo = snd_seq_create_event();
> > >       snd_seq_free_event(foo);
> > >     }
> > >   return 0;
> > > }
> > >
> > > I guess that I have missed some fundamental things about the events.
> > > This on cvs version from 20020504
> >
> > err..  please avoid using snd_seq_create_event(), or free the pointer
> > by normal free() call.  snd_seq_free_event() doesn't free the
> > malloc'ed pointer on alsa 0.9.
> >
> 
> What is the correct way to create an event then?

the event struct is explicitly defined and its size is constant unlike
other structs in API.   thus you can use any allocator as you like,
such as malloc, etc.  if the event can be temporary, use it as a
normal type simply like this:

{
	snd_seq_event_t ev;
	snd_seq_ev_clear(&ev);
	...
	snd_seq_event_output(handle, &ev);
}

snd_seq_event_output() copies the event instance, so a temporary
variable can be used safely in the above.


Takashi

_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: bandwidth@sourceforge.net

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Memory managment.
  2002-05-06 10:37     ` Takashi Iwai
@ 2002-05-06 11:01       ` Peter Enderborg
  2002-05-07  2:18       ` Ville Syrjälä
  1 sibling, 0 replies; 7+ messages in thread
From: Peter Enderborg @ 2002-05-06 11:01 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel@lists.sourceforge.net

Takashi Iwai wrote:

> At Mon, 06 May 2002 12:09:57 +0200,
> Peter Enderborg wrote:
> >
> > Takashi Iwai wrote:
> >
> > > Hi Peter,
> > >
> > > At Sun, 05 May 2002 19:35:04 +0200,
> > > Peter Enderborg wrote:
> > > >
> > > > I have some memory problems with my alsa programming.
> > > > And I have tryed to do a small program to see whats wrong.
> > > > And I still have the same problem with this little program...
> > > >
> > > >
> > > > #include <alsa/asoundlib.h>
> > > > int main()
> > > > {
> > > >   while (1)
> > > >     {
> > > >       snd_seq_event_t *foo;
> > > >       foo = snd_seq_create_event();
> > > >       snd_seq_free_event(foo);
> > > >     }
> > > >   return 0;
> > > > }
> > > >
> > > > I guess that I have missed some fundamental things about the events.
> > > > This on cvs version from 20020504
> > >
> > > err..  please avoid using snd_seq_create_event(), or free the pointer
> > > by normal free() call.  snd_seq_free_event() doesn't free the
> > > malloc'ed pointer on alsa 0.9.
> > >
> >
> > What is the correct way to create an event then?
>
> the event struct is explicitly defined and its size is constant unlike
> other structs in API.   thus you can use any allocator as you like,
> such as malloc, etc.  if the event can be temporary, use it as a
> normal type simply like this:
>
> {
>         snd_seq_event_t ev;
>         snd_seq_ev_clear(&ev);
>         ...
>         snd_seq_event_output(handle, &ev);
> }
>
> snd_seq_event_output() copies the event instance, so a temporary
> variable can be used safely in the above.
>
> Takashi

Then we should remove theh free operation as well, so we get symetric API.

--
foo!




_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: bandwidth@sourceforge.net

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Memory managment.
  2002-05-06 10:37     ` Takashi Iwai
  2002-05-06 11:01       ` Peter Enderborg
@ 2002-05-07  2:18       ` Ville Syrjälä
  1 sibling, 0 replies; 7+ messages in thread
From: Ville Syrjälä @ 2002-05-07  2:18 UTC (permalink / raw)
  To: alsa-devel@lists.sourceforge.net

On Mon, May 06, 2002 at 12:37:29PM +0200, Takashi Iwai wrote:
> snd_seq_event_output() copies the event instance, so a temporary
> variable can be used safely in the above.

What about snd_seq_event_input()? The comments in the code suggest that it
uses snd_seq_event_create() but I don't see it. It doesn't seem to
allocate anything. Do I have to supply it with a pointer to a preallocated
event structure? If that's the case the example code in the alsa-lib/test
directory is broken. Actually it's broken in either case since
like you said snd_seq_free_event() doesn't free anything.

-- 
Ville Syrjälä
syrjala@sci.fi
http://www.sci.fi/~syrjala/

_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: bandwidth@sourceforge.net

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-05-07  2:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-05 17:35 Memory managment Peter Enderborg
2002-05-06  9:42 ` Takashi Iwai
2002-05-06 10:09   ` Peter Enderborg
2002-05-06 10:37     ` Takashi Iwai
2002-05-06 11:01       ` Peter Enderborg
2002-05-07  2:18       ` Ville Syrjälä
  -- strict thread matches above, loose matches on Subject: below --
2002-05-05 14:27 Peter Enderborg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.